问题
I've written a couple of apps which work and seem bug free (ie, they don't crash...) but I get warnings for the code below (which I use a few times) -
In the @interface -
GameViewController *controller;
In the @implementation -
-(id)initWithOwner:(GameViewController *)aController withName:(NSString *)manName {
if (self = [super init]) {
// do stuff
}
controller = aController;
On that last line, it says "Dereference of a null pointer". I'm fairly new to Objective-C (and C as well) so I haven't a clue what it means. Any help & explanation appreciated!
回答1:
Sorry folks - I've found out the problem, after a bit more research. Obviously (at least it's obvious now!) self could end up as nil - see this post: Dereference of Null Pointer
来源:https://stackoverflow.com/questions/4997165/can-someone-explain-dereference-of-a-null-pointer-warning