PDA

View Full Version : KeyValue Problem in CoreData App




bliblablo
Nov 15, 2008, 10:34 AM
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:
id newObj = [super newObject];
[newObj setValue:@"Test" forKey:@"title"];
But with integers i have a problem:
This would be an invalid cast:
[newObj setValue:1 forKey:@"track"];
And this does't work eather:
[newObj setInteger:1 forKey:@"track"];

How can i assign my integer to that key called "track"???

Thx for helping,
greetings, BliBlaBlo



bliblablo
Nov 15, 2008, 10:40 AM
Oh... this is the message i get when calling "openFile" with adding my value by doing:
[newObj setInteger:1 forKey:@"track"];

*** -[NSManagedObject setInteger:forKey:]: unrecognized selector sent to instance 0x19dcb0

kainjow
Nov 15, 2008, 12:10 PM
You could try [newObj setValue:[NSNumber numberWithInt:1] forKey:@"track"];

bliblablo
Nov 16, 2008, 02:53 AM
Great :)
THX!!!