Re: newbie : init ?
Re: newbie : init ?
- Subject: Re: newbie : init ?
- From: Alexander Reichstadt <email@hidden>
- Date: Wed, 12 Jun 2002 01:02:57 -0700
You need to make accessors for your instances.
In your header add
-(NSMutableArray *)listeitem;
-(void)setlisteitem:(NSMutableArray *)value;
In your implementation file add
-(NSMutableArray *)listeitem
{
if (listeitem==nil){
listeitem=[NSMutableArray array];
}
return listeitem;
}
-(void)setlisteitem:(NSMutableArray *)value
{
if (value!=listeitem){
[value retain];
[listeitem release];
listeitem=value;
}
}
In your init method you don't really have to bother about it ay longer,
unless you need to make use of listeitem.
But if you want to, for whatever purpose, you can do this then
-init
{
self = [super init];
[self setlisteitem:[NSMutableArray array]];
return self;
}
Hope there are no typos, but I guess you will figure out if I missed
something.
Alex
On Wednesday, June 12, 2002, at 01:01 AM, Famille GOUREAU-SUIGNARD wrote:
From: Famille GOUREAU-SUIGNARD <email@hidden>
Date: Wed Jun 12, 2002 01:01:55 AM US/Pacific
To: Mailing list cocoa <email@hidden>
Subject: newbie : init ?
Hi,
sorry for this dumb one :
I made my own subclass of NSTextField. It now uses a NSArray.
h
@interface TextFieldAmeliore : NSTextField
{
NSMutableArray *listeItem ;
}
@end
Where does I put the line : listeItem = [[NSMutableArray alloc]
initWithCapacity:0];
I think I should override the init function of NSTextField, but I think
- (id) init
{
listeItem = [[NSMutableArray alloc] initWithCapacity:0];
return self ;
}
is not good.
Why ?
Thanks.
Camille
________
_______________________________________________
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: | |
| >newbie : init ? (From: Famille GOUREAU-SUIGNARD <email@hidden>) |