Re: NSMutableArray Question
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.