• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Adding Custom Objects to a NSMutableArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding Custom Objects to a NSMutableArray


  • Subject: Re: Adding Custom Objects to a NSMutableArray
  • From: Jane <email@hidden>
  • Date: Mon, 28 Jan 2002 06:04:08 -0700

For your initializeWith:Player:Location method, did you declare the method return type as id and then return self from within the method? If not, you would be adding nil to the groups array and the count would remain at 0.

On Sunday, January 27, 2002, at 07:41 AM, Nick wrote:

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
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Adding Custom Objects to a NSMutableArray
      • From: Ondra Cada <email@hidden>
References: 
 >Adding Custom Objects to a NSMutableArray (From: Nick <email@hidden>)

  • Prev by Date: Multi-threaded AppKit examples?
  • Next by Date: Re: Multi-threaded AppKit examples?
  • Previous by thread: Re: Adding Custom Objects to a NSMutableArray
  • Next by thread: Re: Adding Custom Objects to a NSMutableArray
  • Index(es):
    • Date
    • Thread