开发者

SBJson returning nil causing cocoa window to not show up

开发者 https://www.devze.com 2022-12-29 13:00 出处:网络
I\'m using the example here.If there 开发者_如何学Goisn\'t a value for the key, my application returns -[NSCFArray insertObject:atIndex:]: attempt to insert nil in the console, and my window doesn\'t

I'm using the example here. If there 开发者_如何学Goisn'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?


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];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消