NSUndoManager, NSManagedObject and local data
NSUndoManager, NSManagedObject and local data
- Subject: NSUndoManager, NSManagedObject and local data
- From: Pechoultres Xavier <email@hidden>
- Date: Wed, 21 Jun 2006 11:26:44 +0200
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden