刪除對象時,我有,我已經在初始化一個viewDidLoad
NSMutableArray
:崩潰從NSMutableArray的
self.titlesTagArreys = [@[@"Dollar", @"Euro", @"Pound",@"Dollar longString", @"Euro longStringlongString", @"Pound",@"Dollar", @"Euro", @"PoundlongStringlongString"]mutableCopy];
:
@property(nonatomic, copy) NSMutableArray* titlesTagArreys;
當我試圖刪除一個項目,應用程序崩潰:
-(void)removeButtonWasPressed:(NSString*)tagTitle{
NSLog(@"tagTitle - %@",tagTitle);
NSLog(@"self.titlesTagArreys - %@",self.titlesTagArreys);
[self.titlesTagArreys removeObject:tagTitle];
}
這裏是日誌:
2013-08-06 16:15:03.989 EpicTv[6378:907] tagTitle - Dollar
2013-08-06 16:15:03.991 EpicTv[6378:907] self.titlesTagArreys - (
Dollar,
Euro,
Pound,
"Dollar longString",
"Euro longStringlongString",
Pound,
Dollar,
Euro,
PoundlongStringlongString
)
[__NSArrayI removeObject:]: unrecognized selector sent to instance 0x1c53bbd0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI removeObject:]: unrecognized selector sent to instance 0x1c53bbd0'
*** First throw call stack:
(0x327162a3 0x3a5c197f 0x32719e07 0x32718531 0x3266ff68 0x20ad55 0x20c9a5 0x20bf5d 0x346090c5 0x34609077 0x34609055 0x3460890b 0x34608e01 0x345315f1 0x3451e801 0x3451e11b 0x362295a3 0x362291d3 0x326eb173 0x326eb117 0x326e9f99 0x3265cebd 0x3265cd49 0x362282eb 0x34572301 0xafb89 0xa4d68)
libc++abi.dylib: terminate called throwing an exception
可以顯示初始化'NSMutableArray'的代碼,因爲'removeObject'是'NSMutableArray'的有效函數,但錯誤'無法識別的選擇器...'表示'titlesTagArreys'不是'NSMutableArray'。請分享使用'titlesTagArreys'的代碼。 – Popeye
@Luda如何聲明NSMutableArray(titlesTagArreys)? – DharaParekh
Hakuna'NSMutata'。 – dreamlax