我写了一个看起来像这样的函数:
- (void)changeText:(NSUInteger)arrayIndex;
假设这是类 Label 中的一个方法。假设我有一组 Label 对象。我这样调用函数:
[[labels objectAtIndex:0] changeText:1];
或者像这样:
NSUInteger index = 1;
[[labels objectAtIndex:0] changeText:index];
为什么它会给我警告:Passing argument 1 of 'changeText:' makes pointer from integer without a cast
?代码执行正常。
*编辑*
以这些方式调用函数不会给出警告:
[[labels objectAtIndex:0] changeText:0]; //arrayIndex is 0
Label *object = [labels objectAtIndex:0];
[object changeText:1];
最佳答案
更有可能的是,您没有#import
将包含changeText:
定义的头文件导入到任何.m
文件中正在调用它,因此,编译器没有看到方法声明,也不知道参数应该是什么。
或者您定义了一个 changeText:
方法,该方法确实将对象引用作为参数,并且编译器会在编译调用站点之前看到它。
关于iphone - 传递参数使指针来自整数而不进行强制转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5386539/