Я разрабатываю приложение для iPhone 3.1.3.
У меня есть следующий класс:
@interface Pattern : NSObject {
NSMutableArray* shapes;
NSMutableArray* locations;
CGSize bounds;
}
@property (nonatomic, retain, readonly) NSMutableArray* shapes;
@property (nonatomic, retain, readonly) NSMutableArray* locations;
- (id) initWithNumShapes:(int)numShapes screenSize:(CGSize)screenSize;
- (void) addObject:(Object2D*) newObject;
@end
Я не хочу позволять программистам использовать -(id)init;
, потому что яМне нужно настроить мои поля (форму, местоположение, границы) при каждой инициализации.
Я не хочу позволять программистам использовать это:
Pattern* myPattern = [[Pattern alloc] init];
Я знаюКак реализовать:
- (id) initWithNumShapes:(int)numShapes screenSize:(CGSize) screenSize{
if (self = [super init]) {
shapes = [NSMutableArray arrayWithCapacity:numShapes];
locations = [NSMutableArray arrayWithCapacity:numShapes];
bounds = screenSize;
}
return (self);
}
Как я могу это сделать?