Skip navigation.
 
mlNSUndoManager, NSManagedObject and local data
FROM : Pechoultres Xavier
DATE : Wed Jun 21 11:26:44 2006

Hi,
   I need to have a member data in a subclass of NSManagedObject. It's 
a mutable string, allocating when needed and releasing in 
didTurnIntoFault message.
But when I delete the object and use the Undo menu, the object 
reappear well but the local data seems to be released without been 
set to nil.


@interface MyObject : NSManagedObject {
   NSMutableString* _cachedInfo;
}
@end

@implementation MyObject

-(NSString*)info {
   if (_cachedInfo == nil) {
       _cachedInfo = [[NSMutableString stringWithCapacity:0] retain];
       [_cachedInfo appendFormat:@"%@ : %@", [self valueForKey:@"code"], 
[self valueForKey:@"name"]];
   }
   return _cachedInfo;
}

- (void) didTurnIntoFault {
   [_cachedInfo release], _cachedInfo = nil;
   [super didTurnIntoFault];
}

@end

After an Undo, the _cachedInfo as the same adress as before but 
without content !!!

Thanks,


xavier

Related mailsAuthorDate
No related mails found.