Re: create managed object programmaticly
Re: create managed object programmaticly
- Subject: Re: create managed object programmaticly
- From: Jim Correia <email@hidden>
- Date: Tue, 18 Dec 2007 13:16:41 -0500
On Dec 18, 2007, at 12:59 PM, Dominik Pich wrote:
following (partly) the core data low level tutorial I tried created
a managed object for my custom entity by code.
It looks ok but crashes in the 2. NSLog.... well maybe because I
use garbage collection?
code:
- (IBAction)saveJobInHistory:(id)sender {
id destinationObject = [NSEntityDescription
insertNewObjectForEntityForName:[historyController entityName]
inManagedObjectContext:[historyController managedObjectContext]];
if(destinationObject) {
NSLog(@"got instance of entity");
NSLog([destinationObject description]);
}
}
Do not ever pass an arbitrary string you got from somewhere else as a
formatting string to printf, NSLog, etc.
If that string contains formatting characters, you will crash as the
function will try to read va_args that were not passed and get garbage.
The correction form is
NSLog(@"%@", [destinationObject description]);
Jim
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden