Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
938
41
Tokyo, Japan
I thought I understand this topic, but now I got confuse. I have some classes as below, I am not sure if I have to provide a init method, I want to know when I have to have a init when not:
Code:
@interface MarketEvent : NSObject {
    int day;
    NSString *title;
}

@property (nonatomic, assin) int day;
@property (nonatomic, retain) title;
@end

@inplementation MarketEvent
@synthesize year;
@synthesize title;

-(void)dealloc {
    [title release];
    [super dealloc];
}
@end
Code:
@interface MrketEvents : NSObject {
    NSArray *events;
}

@property (nonatomic, retain) NSArray *events;
@end

@inplementation MarketEvents
@synthesize events;

-(void)dealloc {
    [events release];
    [super dealloc];
}
@end
 
Last edited:
You need an init whenever you want any member variables initialized to anything other than 0 or nil.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.