有人可以解释“取消引用空指针"吗?警告 [英] Can someone explain "Dereference of a null pointer" warning
问题描述
我已经编写了一些可以正常运行且看起来没有错误的应用程序(即,它们不会崩溃...),但是我收到以下代码的警告(我使用了几次)-
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) -
在@interface中-
In the @interface -
GameViewController *controller;
在@implementation中-
In the @implementation -
-(id)initWithOwner:(GameViewController *)aController withName:(NSString *)manName {
if (self = [super init]) {
// do stuff
}
controller = aController;
在最后一行,它说取消引用空指针".我对Objective-C(以及C)还很陌生,所以我不知道这意味着什么.任何帮助和解释表示赞赏!
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!
推荐答案
很抱歉-经过更多研究,我已经找到了问题所在.显然(至少现在很明显!)自我可能最终为零-参见以下文章:取消引用空指针
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
这篇关于有人可以解释“取消引用空指针"吗?警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!