I'm using the example here. If there isn't a value for the key, my application returns -[NSCFArray insertObject:atIndex:]: attempt to insert nil
in the console, and my window doesn't show up. How could I preform a check to make sure this doesn't happen?
views:
43answers:
1
+1
A:
Test whether the object pointer is nil
:
if (theObject != nil) {
[myArray insertObject:theObject atIndex:idx];
} else {
//The pointer is nil. This probably means the JSON framework gave you an error object (assuming you enabled it to), in which case, now's probably the time to present it.
if (error != nil)
[NSApp presentError:error];
}
Peter Hosey
2010-05-09 18:46:09