Reputation: 4519
It is possible in Xcode to set empty string as default value of NSString
type attribute? Or [NSDate date]
as default value of NSDate
type attribute?
Upvotes: 4
Views: 3444
Reputation: 3919
You will have to do both programmatically. However, you can't let [NSDate date]
be a default value (since at the time you would set that default value you are simply using the date at the specific time that you set the default value, not when the MO gets created).
You should create a subclass of NSManagedObject
and implement the awakeFromInsert
method:
- (void)awakeFromInsert
{
[super awakeFromInsert];
[self setDateAttribute:[NSDate date]];
[self setStringAttribute:@""];
}
Upvotes: 11