我还想要另一个令人讨厌的警告。基本上,我有一个这样声明的int: @property(nonatomic,assign)int * myInt; 并设置如下: myInt = 0; 。它也在实现文件中合成。我在设置int的值的行上收到警告,并且说指针转换的不兼容intiger从'int'分配给'int *'。我该怎么办解决这个问题?
I have yet another pesky warning I would like gone. Basically, I have an int declared like this: @property (nonatomic, assign) int *myInt; and set like this: myInt = 0;. It is also synthesized in the implementation file. I am getting a warning on the line where I set the int's value and it says Incompatible intiger to pointer conversion assigning to 'int *' from 'int'. What should I do to fix this?
推荐答案错误信息中有一个很大的提示!
There's a big hint in the error message!
在C和Objective C中, int 是原始数据类型。你写了 int * ,这意味着指向一个int的指针,而你看起来只是想要一个int。
In C and Objective C, an int is a primitive data type. You've written int *, which means "a pointer to an int", whereas it looks like you just wanted an int.
所以将您的属性更改为:
So change your property to this:
@property (nonatomic, assign) int myInt;欲了解更多信息,谷歌C指针,你会发现这样的信息: pw1com/~tjensen/ptr/pointers.htm
For more info, google "C pointers" and you'll find information like this: pw1com/~tjensen/ptr/pointers.htm
更多推荐
不兼容的整数到指针转换从'int'分配给'int *'
发布评论