Reputation: 5510
I am trying to replace an object at a particular Index in a NSMutableArray however I am getting this error as shown below
2012-07-30 14:50:11.380 PK[3588:907] -[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x1eded800
2012-07-30 14:50:11.383 PK[3588:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x1eded800'
*** First throw call stack:
(0x357ae56b 0x35a8e97f 0x357b24fb 0x357b0c0d 0x35702e68 0x1082df 0x368528dd 0x3690c869 0x368528dd 0x3685288f 0x3685286d 0x368525c3 0x36852f41 0x36851359 0x3683f2e1 0x3683eb5b 0x385c05f3 0x385c0223 0x3577ec33 0x3577ebd7 0x3577d9d1 0x356fbc1d 0x356fbaa9 0x385bf33b 0x36865535 0x104175 0x344c6b20)
libc++abi.dylib: terminate called throwing an exception
I have declared the the array as an NSMutableArray in the header so it is widely avalible to any method wanting to use it, and below is showing how I use it when trying to set up an NSDictionary object.
//...
// Objects for keys that are for sendSeriesDictionary
seriesObjects = [NSArray arrayWithObjects: [NSNull null], [NSNull null], [NSNull null], nil];
if ([manufactureIdString length] != 0) {
[seriesObjects replaceObjectAtIndex:0 withObject:IdString];
}
if ([modelIdString length] != 0) {
[seriesObjects replaceObjectAtIndex:1 withObject:mIdString];
}
if ([subModelIdString length] != 0) {
[seriesObjects replaceObjectAtIndex:2 withObject:sIdString];
}
//..
as soon as the thread enters the first if statment is when I get the error listed above.. The reason I have initaly set the NSMutableArray to [NSNull null], is that that if any of the 3 strings are empty that object in the array will not screw things up further down the track when this data is passed across as a call to the server I am communicating with.
Any help would be greatly appreciated... I feel like what I am doing should work, however I also think that maybe the error is being cause by me passing in [NSNull null] in the array objects.. but thats just my observation maybe you guys can tell me more about the situation.
Upvotes: 0
Views: 1894
Reputation: 39988
Create a Mutable array like this
seriesObjects = [NSMutableArray arrayWithObjects: [NSNull null], [NSNull null], [NSNull null], nil];
and declare seriesObjects
as
NSMutableArray *seriesObjects;
to remove warnings
Upvotes: 2