core data - problem with automatically filled-in index

Discussion in 'Mac Programming' started by schoeringhumer, Sep 6, 2009.

  1. schoeringhumer macrumors newbie

    Sep 2, 2009

    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,

  2. schoeringhumer thread starter macrumors newbie

    Sep 2, 2009
    ... here is the picture ... sry for second post

    Attached Files:

  3. Eraserhead macrumors G4


    Nov 3, 2005
    You could do it with a custom add method when new rows are added to the table. As in:

    NSManagedObject *lastGSL = [[globalSpellLevelController arrangedObjects] lastObject];
    	int level;
    	if(lastGSL == nil){
    		level = 1;
    		level = [[lastGSL valueForKey:@"level"] intValue]+1;
    	NSManagedObject *newGSL = [globalSpellLevelController newObject];
    	[newGSL setValue:[NSNumber numberWithInt: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.

Share This Page