无法弄清楚为什么这个错误不断被抛出:
-[__NSCFString bytes]: unrecognized selector sent to instance 0xc3eb200
对于此代码:
- (void)parser:(SBJsonStreamParser *)parser foundObject:(NSDictionary *)dict {
empty = NO;
for (NSDictionary *valueDictionary in [dict objectForKey:@"Contacts"]) {
if ([[valueDictionary objectForKey:@"Empty"] isEqualToString:@"YES"]){
empty = YES;
contactsArray = [[NSMutableArray alloc] init];
}else{
Thecontacts = [valueDictionary objectForKey:@"Contacts"];
}
dataRepresentingSavedArray = Thecontacts;
if (dataRepresentingSavedArray != nil) {
**Causes Error->** NSArray *oldSavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:dataRepresentingSavedArray];
contactsArray = [[NSMutableArray alloc] initWithArray:oldSavedArray];
}
}
[table reloadData];
}
[valueDictionary objectForKey:@"Contacts"] 的值为
<62706c69 73743030 d4010203 0405082b 2c542474 6f705824 6f626a65 63747358 24766572 73696f6e 59246172 63686976 6572d106 0754726f 6f748001 ab090a11 1718191a 2228292a 55246e75 6c6cd20b 0c0d0e56 24636c61 73735a4e 532e6f62 6a656374 738006a2 0f108002 8007d20b 0c0d1380 06a31415 16800380 0480055b 416e6472 65772044 756e6e5f 1018616e 64726577 4064756e 6e2d6361 72616261 6c692e63 6f6d5661 63636570 74d21b1c 1d215824 636c6173 7365735a 24636c61 73736e61 6d65a31e 1f205e4e 534d7574 61626c65 41727261 79574e53 41727261 79584e53 4f626a65 63745e4e 534d7574 61626c65 41727261 79d20b0c 0d248006 a3252627 80088009 800a5e4a 6f686e20 4170706c 65736565 645f1016 4a6f686e 2d417070 6c657365 6564406d 61632e63 6f6d5561 6c657274 12000186 a05f100f 4e534b65 79656441 72636869 76657200 08001100 16001f00 28003200 35003a00 3c004800 4e005300 5a006500 67006a00 6c006e00 73007500 79007b00 7d007f00 8b00a600 ad00b200 bb00c600 ca00d900 e100ea00 f900fe01 00010401 06010801 0a011901 32013801 3d000000 00000002 01000000 00000000 2d000000 00000000 00000000 00000001 4f>
我一直在玩代码并且接近最终分辨率它很讨厌,但它会工作,直到我找到解决方法。所以 oldSavedArray 打印数组但是当我去打印这个
contactsArray = [[NSMutableArray alloc] initWithArray:oldSavedArray];
我收到这个。
[__NSCFString count]: unrecognized selector sent to instance 0xabab970
oldSavedArray 的输出是
((“John Appleseed”,“John-Appleseed@mac.com”,警报),(“Andrew Dunn”,“andrew@me.com”,接受))
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[AsyncURLConnection request:url completeBlock:^(NSData *data) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
NSString *myString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if (![myString isEqualToString:@"0"]) {
[[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:myString] forKey:@"savedArray"];
NSArray *oldSavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:@"savedArray"]];
contactsArray = [[NSMutableArray alloc] initWithArray:oldSavedArray];
[table reloadData];
}else{
contactsArray = [[NSMutableArray alloc] init];
}
});
});
} errorBlock:^(NSError *errorss) {
}];