KeyValue Problem in CoreData App

Discussion in 'Mac Programming' started by bliblablo, Nov 15, 2008.

  1. bliblablo macrumors newbie

    Joined:
    Oct 20, 2008
    #1
    Hey

    I have an entity which contains an attribute called "track" and it is a integer.
    The attribute is bint to a tableview.
    Now i have an ArrayController and in there i have a method named "openFile"
    Everything works for strings:
    Code:
    id newObj = [super newObject];
    [newObj setValue:@"Test" forKey:@"title"];
    But with integers i have a problem:
    This would be an invalid cast:
    Code:
    [newObj setValue:1 forKey:@"track"];
    And this does't work eather:
    Code:
    [newObj setInteger:1 forKey:@"track"];
    How can i assign my integer to that key called "track"???

    Thx for helping,
    greetings, BliBlaBlo
     
  2. bliblablo thread starter macrumors newbie

    Joined:
    Oct 20, 2008
    #2
    Oh... this is the message i get when calling "openFile" with adding my value by doing:
    Code:
    [newObj setInteger:1 forKey:@"track"];
    Code:
    *** -[NSManagedObject setInteger:forKey:]: unrecognized selector sent to instance 0x19dcb0
     
  3. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #3
    You could try [newObj setValue:[NSNumber numberWithInt:1] forKey:mad:"track"];
     
  4. bliblablo thread starter macrumors newbie

    Joined:
    Oct 20, 2008

Share This Page