Мое приложение постоянно получает nsnotification с информацией о местонахождении моих iBeacons. Когда я включаю службы определения местоположения, приложение прерывается с ошибкой «невозможно сериализовать userInfo: (null)». Без служб определения местоположения приложение работает нормально. Без загрузки из базы данных код работает нормально.
Проблема может быть в том, как я рисую данные.
- (void)retrieveData
{
dispatch_queue_t callerQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_queue_t downloadQueue = dispatch_queue_create("Lots of requests", NULL);
dispatch_async(downloadQueue, ^{
NSString *stringURL = [NSString stringWithFormat:@"http://livveknowingly.com/dataDraw.php"];
NSURL *url = [NSURL URLWithString:stringURL];
NSURLResponse *response;
NSError *error;
NSData *data = [NSURLConnection sendSynchronousRequest:[[NSURLRequest alloc]initWithURL:url] returningResponse:&response error:&error];
_json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//NSLog(@"Here is the json %@", _json);
_beaconsArray = [[NSMutableArray alloc] init];
BeaconsArray *ba = [BeaconsArray singleton];
for (int i = 0; i < _json.count; i++)
{
//create object
NSString *title = [[_json objectAtIndex:i] objectForKey:@"title"];
NSString *imageName = [[_json objectAtIndex:i] objectForKey:@"image"];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat: @"http://livveknowingly.com/imageUploads/museumTest/%@", imageName]]]];
// NSData *new = [[NSData alloc] initWithBase64EncodedData:[[_json objectAtIndex:i] objectForKey:@"image"] options:0];
//UIImage *image = [UIImage imageWithData:new];
NSString *description = [[_json objectAtIndex:i] objectForKey:@"description"];
NSString *webLink = [[_json objectAtIndex:i] objectForKey:@"webLink"];
NSString *questionOne = [[_json objectAtIndex:i] objectForKey:@"questionOne"];
NSString *questionTwo = [[_json objectAtIndex:i] objectForKey:@"questionTwo"];
NSString *hintImageOne = [[_json objectAtIndex:i] objectForKey:@"hintImageOne"];
NSString *hintImageTwo = [[_json objectAtIndex:i] objectForKey:@"hintImageTwo"];
NSString *supBeaconOne = [[_json objectAtIndex:i] objectForKey:@"supBeaconOne"];
NSString *supBeaconTwo = [[_json objectAtIndex:i] objectForKey:@"supBeaconTwo"];
[ba.beaconsArray addObject:[[Exhibit alloc] initWithInfo:title andImage:image andDesc:description andWeb:webLink andQuesOne:questionOne andQuesTwo:questionTwo andHintOne:hintImageOne andHintTwo:hintImageTwo andSubBeaconOne:supBeaconOne andSubBeaconTwo:supBeaconTwo]];
NSLog(@"aaaaaaaaaaa, %@", ba.beaconsArray);
}
});
dispatch_async(callerQueue, ^{ });
}
Меня переводит на main.m. Вот точная ошибка:
2014-03-16 17:29:13.603 RoximityTest[1012:60b] Property list invalid for format: 200 (property lists cannot contain objects of type 'CFNull')
2014-03-16 17:29:13.605 RoximityTest[1012:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'unable to serialize userInfo: (null)'
*** First throw call stack:
(0x2dba2f4b 0x383396af 0x30770927 0x856c7 0x853d7 0x850df 0xb3ebd 0x2e06587b 0x2e059bd3 0x2db6e1b1 0x2db6d533 0x2db6c1a1 0x2dad6c27 0x2dad6a0b 0x327ca283 0x3037a049 0x7b6dd 0x38841ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException