Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

schoeringhumer

macrumors newbie
Original poster
Sep 2, 2009
9
0
hi,

i have a problem with a core data binding ....

i bound my lieferschein_id column with a indexed core data attribute which has as type integer 32

when i want to add a new entry to my application, i would want to automatically insert the id ... which would be in this context 1,2,3, ..... into the lieferschein_id column ....

does anybody know how i have to do to insert the id .... ? ...

in the binding ... the controller key is arrangedObjects and the Model Key Path is lieferschein_id ...


any ideas ? ....


thanks for helping,

schoeringhumer
 
... here is the picture ... sry for second post
 

Attachments

  • Bildschirmfoto 2009-09-06 um 15.12.50.png
    Bildschirmfoto 2009-09-06 um 15.12.50.png
    21.6 KB · Views: 74
You could do it with a custom add method when new rows are added to the table. As in:

Code:
NSManagedObject *lastGSL = [[globalSpellLevelController arrangedObjects] lastObject];
	int level;
	if(lastGSL == nil){
		level = 1;
	}else{
		level = [[lastGSL valueForKey:@"level"] intValue]+1;
	}
	NSManagedObject *newGSL = [globalSpellLevelController newObject];
	[newGSL setValue:[NSNumber numberWithInt:level]
			  forKey:@"level"];
	[globalSpellLevelController addObject:newGSL];

Alternatively you could do it properly in the init method for a custom subclass of NSManagedObject, though what you'd call to set it I don't know.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.