Re: Method not seeing array as array
Re: Method not seeing array as array
- Subject: Re: Method not seeing array as array
- From: Andrew Farmer <email@hidden>
- Date: Wed, 2 Feb 2005 12:21:23 -0800
On 2 Feb 2005, at 11:31, Michael Swan wrote:
<snip>
@implementation AppController
- (id)init
{
[super init];
channelArray = [[NSMutableArray alloc] init];
masterLevel = 100.0;
maxChannels = 12;
int theTag;
theTag = 0;
//init channels and put into array
//Putting the channelArray code here works for the updateOutput
method but not
//for the changeChannelLevel: method
/* this code just makes the app crash still have to figure out the
short way
while (theTag < maxChannels) {
channel = [[MSChannel alloc] init];
[channelArray addObject:channel];
NSLog(@"channel %@ added",[channelArray count]);
[channel release];
theTag++;
}
*/
return self;
}
The standard pattern for an initialization is:
- (id)init
{
self = [super init]; // <-- note that we're initializing `self' here!
if(!self) return nil;
// initialize variables, etc
return self;
}
I don't know what exactly happens if you don't initialize `self', but
your problems are probably stemming from this issue.
Attachment:
PGP.sig
Description: This is a digitally signed message part
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden