This means that the object wasn't found 2147483647 == NSNotFound
What you're trying to do is save a array of objects, and then read them back out to a varaible. Doing this will create (alloc
/init
) the objects again so they won't occupy the same location in memory. Depending on how you implement your encoder/decode methods, the object might be exactly the same as the other one (content wise). What you need to do is override isEqual:
(and hash
) in your class and check the objects in there.
If you're objects have some kind of ID
property you can just do:
-(BOOL)isEqual:(id)object
{
if (self == object) {
return YES;
}
if (![object isKindOfClass:[self class]]) {
return NO;
}
return [self.ID isEqual:object.ID];
}
If none of your properties on your object are unique, you can check each one in the isEqual:
method.
See this answer for more info.