如何将nil添加到nsmutablearray? [英] how to add nil to nsmutablearray?
本文介绍了如何将nil添加到nsmutablearray?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
NSArray * array = [[NSArray alloc] initWithObjects:@ΕΛΤΑ,
@ΕΛΤΑCOURIER,@ACS,@ACSΕΞΩΤΕΡΙΚΟ,
@DHL,@INTERATTICA,@SPEEDEX,
@UPS,@ΓΕΝΙΚΗΤΑΧΥΔΡΟΜΙΚΗ,@ΜΕΤΑΦΟΡΙΚΕΣΕΞΩΤΕΡΙΚΟΥ,nil];
这是有效的,因为它最后没有。
但是我添加了这样的对象: addObject:name
etc ...
所以最后我必须添加nil我这样做addObhect:没有,但是当我运行应用程序时,它仍然会在 cellForRowAtIndexPath崩溃:
我该怎么做才能做到这一点?
好的,我没有添加nil
我的应用程序崩溃的原因是什么?
解决方案
当你调用 addObject
时,你不能添加nil。 / p>
NSArray *array = [[NSArray alloc] initWithObjects:@"ΕΛΤΑ",
@"ΕΛΤΑ COURIER", @"ACS", @"ACS ΕΞΩΤΕΡΙΚΟ",
@"DHL", @"INTERATTICA", @"SPEEDEX",
@"UPS", @"ΓΕΝΙΚΗ ΤΑΧΥΔΡΟΜΙΚΗ", @"ΜΕΤΑΦΟΡΙΚΕΣ ΕΞΩΤΕΡΙΚΟΥ", nil];
This is working because it has nil at the end.
But I add objects like this: addObject:name
etc...
So at the end I have to add nil I do this addObhect:nil but when I run the app it still crashes at cellForRowAtIndexPath:
how can I do this work?
Ok, I dont have to add nil
What is the reason that my app crashes then?
解决方案
You can't add nil when you're calling addObject
.
这篇关于如何将nil添加到nsmutablearray?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文