传递参数使得指针来自整数而没有强制转换

Jus*_*tin 2 iphone objective-c ios

我写了一个看起来像这样的函数:

- (void)changeText:(NSUInteger)arrayIndex;
Run Code Online (Sandbox Code Playgroud)

我们只是说这是Label类中的一个方法.假设我有一个Label对象数组.我把这个函数称为:

[[labels objectAtIndex:0] changeText:1];
Run Code Online (Sandbox Code Playgroud)

或者像这样:

NSUInteger index = 1;
[[labels objectAtIndex:0] changeText:index];
Run Code Online (Sandbox Code Playgroud)

为什么它会给我警告: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];
Run Code Online (Sandbox Code Playgroud)

bbu*_*bum 5

更可能的情况是,你没有#import包含调用它的changeText:任何.m文件的定义的头文件,因此,编译器没有看到方法声明,也不知道论证应该是什么.

或者你有一个changeText:定义的方法确实将对象引用作为参数,编译器在编译调用站点之前就会看到它.