I have nsmutable array and I want to add object at particular index, how can I check if the array at particular index has a object or not?
I was doing this:
if ([self.myArray objectAtIndex:index] !=nil) {
but I’m getting exceptions most of the time because “beyond bounds”
I’ll really appreciate your help
It is my understanding that you cannot have an index of an array unless you have and object there. What I would suggest is to set all indexes in the array to
[NSNull null]and then in your if statement check to see if the object at that index is an NSNull object.if([[self.myArray objectAtIndex:index] isKindOfClass:[NSNull class]])then if that returns true, have it replace the null object with your object