Adding Custom Objects to a NSMutableArray
Adding Custom Objects to a NSMutableArray
- Subject: Adding Custom Objects to a NSMutableArray
- From: Nick <email@hidden>
- Date: Sun, 27 Jan 2002 21:41:35 +0700
My sincerest apologies if there is an obvious answer to this question
that I have carelessly overlooked, but I can't seem to find what the
problem is and would greatly appreciate any help.
I have a custom class called Monopoly Checker. Inside a different set
of code, I create 40 of these objects and put them into a NSMutableArray
for later access.
The code:
...
MonopolyChecker *temp;
NSNumber *a, *b;
...
a = [NSNumber numberWithInt:1];
b = [NSNumber numberWithInt:3];
array = [NSArray arrayWithObjects:a,b,nil];
temp = [[MonopolyChecker alloc] init];
[temp initializeWith:array Player:playerArray Location:locationArray];
[groups addObject:temp];
where "groups" is an NSMutableArray declared earlier.
For some reason, although this code seems correct to me, the object is
never added to the array. I have confirmed that each temp object is
created, and can receive messages, but after the addObject: message, the
count of the array remains at 0 and no objects inside the array respond
to messages sent to them.
I am not receiving any error messages when I add the object or try to
access it, but I see no evidence of it being added.
Any help would be greatly appreciated, my apologies again if this newbie
question is merely taking up space.
--Nick
email@hidden