NSArray * kickOff10(NSArray *array){
NSMutableArray *p =[NSMutableArray arrayWithArray:array];
while([p containsObject:@10]){
[p removeObject:@10];
}
return p;
}
int main()
{
NSArray *array = @[@10,@"ehee",@"haha",@10];
array = kickoff10(array);
NSLog(@"%@",array);
return 0;
}
//结束.
array = kickoff10(array);这一行有三个bug
两个警告:
1.Incompatible integer to pointer conversion assigning to “NSArray *__strong” from “int”
2.implicit declaration of function “kickoff10” is invalid in C99.
一个错误:
implicit conversion of “int” to “NSArray *” is disallowed with ARC.
都没弄懂.
但是我换成
int main()
{
NSArray *array = @[@10,@"ehee",@"haha",@10];
NSMutableArray *p =[NSMutableArray arrayWithArray:array];
while([p containsObject:@10]){
[p removeObject:@10];
}
array = p;
NSLog(@"%@",array);
return 0;
}
就没有问题,求前辈解答.为什么呢,如何抽出函数呢? |
|