I’m able to get today’s date using the following in Objective-c:
NSDate *date =[NSDate date];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
df.dateStyle = NSDateFormatterLongStyle;
[ASFunctions logThis:@"formatted date:" andThisObject:[df stringFromDate:date]];
However, I also want to insert this into a SQLite database using the Core Data framework.
I have been able to insert user entered text using the following:
Project.name = text.nameTextField.self;
Where project.name is the entity name and attribute. I am using project.dateStarted to store the date.
After grabbing the date using the functions above, how would I store it into the project.dateStarted attribute of the core database?
If dateStarted is defined as a date attribute in the model, just assign the NSDate to it and save the context.
will do the trick.