Re: Adding Custom Objects to a NSMutableArray
Re: Adding Custom Objects to a NSMutableArray
- Subject: Re: Adding Custom Objects to a NSMutableArray
- From: Ondra Cada <email@hidden>
- Date: Sun, 27 Jan 2002 15:57:56 +0100
Nick,
>
>>>>> Nick (N) wrote at Sun, 27 Jan 2002 21:41:35 +0700:
N> temp = [[MonopolyChecker alloc] init];
N> [temp initializeWith:array Player:playerArray Location:locationArray];
N> [groups addObject:temp];
N>
N> where "groups" is an NSMutableArray declared earlier.
Created too? If not, see (**)!
N> For some reason, although this code seems correct to me, the object is
N> never added to the array. I have confirmed that each temp object is
N> created, and can receive messages, but after the addObject: message, the
N> count of the array remains at 0 and no objects inside the array respond
N> to messages sent to them.
That looks weird indeed (unless (**) below). So far as the code snippet
goes, all is perfectly right (perhaps but that initializeWith: is not called
quite nicely lest it be confused with init... methods, but that's cosmetics).
N> I am not receiving any error messages when I add the object or try to
N> access it, but I see no evidence of it being added.
The most obvious reason would be groups==nil (**), but I reckon you've
checked (if not, do immediately! ;)
Otherwise, try this and send result:
temp = [[MonopolyChecker alloc] init];
[temp initializeWith:array Player:playerArray Location:locationArray];
NSLog(@"temp %x:%@ -- %@",temp,[temp class],temp);
NSLog(@"groups %x:%@ (%d) -- %@",groups,[groups class],[groups count],groups);
[groups addObject:temp];
NSLog(@"groups %x:%@ (%d) -- %@",groups,[groups class],[groups count],groups);
Note: should the program crash inside on of the logs, divide those composed
logs to more single-argument ones, so as you see which one of them crashed.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc