大家好,我是 Xcode/iOS 开发的新手
我试图将 json 数据添加到可变数组中,这会导致应用程序崩溃:( 到目前为止,这是我的代码:
if(! [defaults objectForKey:@"Person1"])
[defaults setObject:[PersonsFromSearch objectAtIndex:index] forKey:@"Person1"];
else
{
NSMutableArray *Array = [[NSMutableArray alloc]init];
id object = [defaults objectForKey:@"Person1"];
Array = [object isKindOfClass:[NSArray class]] ? object : @[object];
[Array addObject:[PersonsFromSearch objectAtIndex:index]];//crash here :((
[Array moveObjectFromIndex:[Array count] toIndex:0];
}
崩溃转储:
* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSArrayI addObject:]:无法识别的选择器发送到实例 0xcb4d380”*第一次抛出调用堆栈:
这里有什么问题?你能帮我解决这个问题吗
数组包含这个(Json?)
{
Address = "\U05d3\U05e8\U05da \U05d4\U05e9\U05dc\U05d5\U05dd 53";
CellPhone = "052-3275381";
EMail = "editor@pc.co.il";
EnglishPerson = "Yehuda Konfortes";
FaceBookLink = "";
Fax1 = "03-7330703";
Fax2 = "";
FileNAme = "100050.jpg";
HomeEMail = "";
HomeFax = "";
HomePhone1 = "";
HomePhone2 = "";
PersonID = 100050;
PersonName = "\U05d9\U05d4\U05d5\U05d3\U05d4 \U05e7\U05d5\U05e0\U05e4\U05d5\U05e8\U05d8\U05e1";
Phone1 = "03-7330733";
Phone2 = "";
ZipCode = "";
}