How to simplify the code?
- by Tattat
I have objectA, and objectB.... also I have objectAs, and objectBs.
the objectA is only have the init method, and ObjectAs have somethings like this:
#import "ObjectAs.h"
@implementation ObjectAs
@synthesize objectAs;
-(id) init{
if( (self=[super init])) {
self.objectAs = [[NSMutableArray alloc] init];
}
return self;
}
-(int)getObjectAsNumber{
return [self.objectAs count];
}
-(void)addObjectA:(ObjectA *)newObjectA{
[self.objectAs addObject:newObjectA];
}
-(id)getObjectAByIdx:(int)objectAIdx{
return [self.objectAs objectAtIndex:objectAIdx];
}
-(void)dealloc{
[super dealloc];
[objectAs release];
}
@end
The objectBs have similar have, I know that I can copy and paste, and replace it. Is there any way to simplify the objectBs, and objectAs? thz a lot.