• 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: NSMutableArray Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray Question


  • Subject: Re: NSMutableArray Question
  • From: Andreas Mayer <email@hidden>
  • Date: Fri, 31 Oct 2003 11:00:15 +0100

Am 31.10.2003 um 09:06 schrieb John Mullins:

And I would like to make an NSMutableArray of a group of Sample
classes.

While it's possible, you usually won't want to put classes in arrays. Instead, you put _instances of classes_ in arrays.

I can't really figure out how to make an NSMutableArray with
objects.

NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease];

[array addObject:someObject];

And once I have like ObjectAtIndex: how do I call mPlayID from it?

You will need an appropriate accessor in your Sample class. Something like

- (AudioFilePlayID)mPlayID {
return mPlayID;
}

Then you can tell your Sample object to return it's mPlayID:

AudioFilePlayID theID = [[array objectAtIndex:someIndex] mPlayID];

I need to pass mPlayID as a reference.. like &sample.mPlayID would be in
C.... to a method.

Pass it to whom?

If you want to play it, why not implement a play method in your Sample class:

- (void)play {
someObscureCFunction(&mPlayID);
}

This way you could just write

[[array objectAtIndex:someIndex] play];


bye. Andreas.
_______________________________________________
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.

References: 
 >NSMutableArray Question (From: John Mullins <email@hidden>)

  • Prev by Date: Creation of constants
  • Next by Date: NSOutputStream pb
  • Previous by thread: Re: NSMutableArray Question
  • Next by thread: XCode or code problems?
  • Index(es):
    • Date
    • Thread