Re: "Default" Value In Object
Re: "Default" Value In Object
- Subject: Re: "Default" Value In Object
- From: Thaddeus Cooper <email@hidden>
- Date: Sat, 18 Jun 2005 13:31:39 -0700
Per your suggestion, I implemented the new array controller, and in the
debugger I can see the new newObject method being called -- only
problem is -- controlTextDidEndEditing never seems to get called. Do I
need to hook it up or should it just work? The documentation seems to
suggest the latter, but...
--Thaddeus O. Cooper
(email@hidden)
On Jun 17, 2005, at 11:01 PM, mmalcolm crawford wrote:
To elaborate on the approach I suggested before, you could implement a
newObject method in your array controller subclass that does something
like:
- (id)newObject {
NSManagedObect *newObject = (NSManagedObect *)[super newObject];
[newObject setValue:lastSetValue forKey:@"keyName"];
return newObject;
}
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
[self setLastSetValue:[[aNotification object] stringValue]];
}
- (NSString *)lastSetValue { return lastSetValue; }
- (void)setLastSetValue:(NSString *)aLastSetValue
{
if (lastSetValue != aLastSetValue) {
[lastSetValue release];
lastSetValue = [aLastSetValue copy];
}
}
lastSetValue might be a local variable as suggested here, or you could
store it in user defaults. You could also maintain it as document- or
application-wide state, and add it to the metadata for the persistent
store on save.
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
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