0

My application continually recieves a nsnotification giving info as to the location of my iBeacons. When I turn on location services the app breaks with an error of 'unable to serialize userInfo: (null)'. Without location services on the app works fine. Without loading from a database the code works fine.

The problem may be in the way I draw the data.

- (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, ^{ });
}

It takes me to main.m. Here is the exact error given:

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
cgauss
  • 324
  • 3
  • 16
  • Please provide some more information, such as the line of your code where the exception occurs. Also, this answer may provide a clue - http://stackoverflow.com/questions/4637179/uilocalnotification-crash – Paulw11 Mar 16 '14 at 21:09
  • Well, the exception message is clear and correct - you cannot put null into a propertylist. Do you have an exception breakpoint active? This should help you find the actual location where you are updating the propertylist – Paulw11 Mar 16 '14 at 21:55
  • @Paulw11 the property list is set by a third party library I must implement in order to recognize my beacons – cgauss Mar 17 '14 at 00:11
  • An exception breakpoint may still help. If you don't have access to the 3rd party library source code then you may need to review their documentation closely as they may be putting an object into the plist supplied by you, for which you have either not supplied a value or supplied nil/null. You may also need to raise an incident with the 3rd party support – Paulw11 Mar 17 '14 at 00:30
  • using a for (NSDictionary *dict in _json) would be much more efficient that a for (int i = 0; ...) each [_json objectAtIndex:i] has a cost. Also, before creating your Exhibit instance, please check all of your values – Jerome Diaz Apr 03 '14 at 09:55
  • an other point, if BeaconsArray *ba = [BeaconsArray singleton]; is to contains a list of beacons, why don't you have BeaconsArray inherit from NSMutableArray instead of it having a NSMutableArray has a property ? (ba.beaconsArray) – Jerome Diaz Apr 03 '14 at 09:57

0 Answers0