不兼容的指针类型用“NSArray *"类型的表达式初始化“NSMutableArray *" [英] Incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'
问题描述
这是我的代码导致上述警告:
This is my code that is causing the above warning:
NSMutableArray *tbValueArray = [NSArray arrayWithObjects:oServices1.text,
oServices2.text,oServices3.text,oServices4.text,oServices5.text,oServices6.text,
oServices7.text,oServices8.text,oServices9.text,oServices10.text,oServices11.text,
oServices12.text,oServices13.text,oServices14.text,oServices15.text,oServices16.text,
oServices17.text,oServices18.text,oServices19.text,oServices20.text,oServices21.text,
oServices22.text,oServices23.text,oServices24.text,nil];
我该如何更改以消除警告?(我查看了 Google 和 SO 并没有发现任何适用的内容).
How do I change this to remove the warning? (I have looked at Google and SO and found nothing that applies).
推荐答案
您是要创建 NSMutableArray 还是 NSArray?您已将变量声明为 NSMutableArray*
类型,但右侧的表达式创建了一个 NSArray.如果你希望这个数组是可变的,请将 arrayWithObjects:
的接收者更改为 NSMutableArray;如果不是,请更改声明以将其正确标识为 NSArray 而不是 NSMutableArray.
Are you trying to create an NSMutableArray or an NSArray? You have declared the variable as being of type NSMutableArray*
, but the expression on the right creates an NSArray. If you want this array to be mutable, change the receiver of arrayWithObjects:
to be NSMutableArray; if not, change the declaration to correctly identify this as an NSArray instead of an NSMutableArray.
这篇关于不兼容的指针类型用“NSArray *"类型的表达式初始化“NSMutableArray *"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!