I want to store tuples of 2 ints and a char in an NSArray.
Is there an easyer way than to declare an class holding the 2 ints and the char?
I tryed it this way and it works, but it seems rather complicated to me. Is there a better and easyer way?
@interface Container : NSObject
@property NSInteger a;
@property NSInteger b;
@property char c;
@end
@implementation Container
@synthesize a = _a;
@synthesize b = _b;
@synthesize c = _c;
-(Container*) initWitha:(NSInteger) a andB:(NSInteger) b andC: (char) c
{
if ((self = [super init])) {
self.a = a;
self.b = b;
self.c = c;
}
return self;
}
@end
...
//usage
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject: [[Container alloc] initWitha:5 andB:6 andC:'D']];
Thanks
Maybe you could just use a C struct ?
then you could do something like