我有一个带有 11 个元素的 NSMutableArray “array1” 我想在第一个位置再插入一个字符串,我该怎么做?我尝试了以下代码,但是这个抛出异常
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *categoryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"list.plist"];
categoryList = [[NSDictionary alloc] initWithContentsOfFile:categoryPath];
NSMutableArray *Name=[[NSMutableArray alloc]init];
Name=[[categoryList objectForKey:@"catlist"] valueForKey:@"category_name"];
NSString *str=@"Rahul";
[categoryName insertObject:str atIndex:0];
例外
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI insertObject:atIndex:]: unrecognized selector sent to instance 0x8349e30'
*** First throw call stack:
(0x2465052 0x1738d0a 0x2466ced 0x23cbf00 0x23cbce2 0x6f690 0x6f402 0x96e64e 0x7123c 0x930a5 0x96e64e 0x96dc1c 0x99456d 0x97ed47 0x995441 0x99545d 0x9954f9 0x97f213 0xb24fbd 0xb24ccb 0x9812b7 0x9813df 0x97ed9b 0x995441 0x99545d 0x9954f9 0x8d5d65 0x8d5dac 0x8a6be6 0x8a78a6 0x8b6743 0x8b71f8 0x8aaaa9 0x3922fa9 0x24391c5 0x239e022 0x239c90a 0x239bdb4 0x239bccb 0x8a72a7 0x8a8a9b 0x2f2d 0x2e55 0x1)
terminate called throwing an exception(lldb)