Newbie-setting object used as variable of another object
Newbie-setting object used as variable of another object
- Subject: Newbie-setting object used as variable of another object
- From: Steve Gran <email@hidden>
- Date: Mon, 23 Jan 2006 23:10:46 -0800
Because I'm just a "hobby programmer" I often run across concepts I
just don't grasp. Especially as I move from very simplistic programs
to more complex ones (well, let me qualify that, complex for
me...probably very simplistic for you guys).
So, can someone help me out on this one. I have an object (which has
variables of it's own) as a variable of another object but I can't
seem to set values to the object that is a variable. This little app
has People objects who have various variables (NSString, etc.) as
well as a variable that is another object (a Things object which has
itself two variables: a NSString and an int).
In my app controller I'm loading data into an array of People objects
(it's just from a text file, comma separated values). I understand
how to init a new object and set values using KVC. But I can't seem
to get it to work with the Things object.
Here's a snipit of the method in my app controller that loads the csv
file into my array...
[peopleArray addObject: aPerson = [[People alloc] init]];
[aPerson setValue:[tmpArray objectAtIndex:0] forKey:@"personID"];
[aPerson setValue:[tmpArray objectAtIndex:1] forKey:@"personName"];
This works fine and my aPerson object has values set correctly.
Things *aThing;
aThing = [[Things alloc] initWithName: @"First" andThingValue:
[[tmpArray objectAtIndex:2] intValue]];
And this part works (using NSLog I can see that aThing is also set
correctly.
[aPerson setValue:aThing forKey:@"thing"];
But this doesn't. I get a message in the console that says...
-[Things copyWithZone:]: selector not recognized [self = 0x30ed10]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden