How to simplify the code?

Posted by Tattat on Stack Overflow See other posts from Stack Overflow or by Tattat
Published on 2010-04-22T16:30:31Z Indexed on 2010/04/22 16:33 UTC
Read the original article Hit count: 172

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.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about object-oriented-design