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

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
I have an object HomeControlGroup which contains a Mutable Array of HomeControlAppliances

Code:
@class HomeControlAppliance;

@interface HomeControlGroup : NSObject {
	NSString		*groupName;
	NSInteger		groupNumber;
	NSMutableArray	*homeControlAppliances;
}
@property (nonatomic,retain) NSString	*groupName;
@property (nonatomic,assign) NSInteger	groupNumber;
@property (nonatomic,retain) NSMutableArray	*homeControlAppliances;

- (id) initGroup: (NSString *) newName  groupNumber: (NSInteger)newNumber;
- (void) addHomeControlAppliance: (HomeControlAppliance *) newAppliance;

@end
I can create an array of Groups initialised thus:
Code:
- (id) initGroup: (NSString *) newName  groupNumber: (NSInteger)newNumber {
	self = [super init];
	if (self != nil) {
		self.groupName =  newName;
		self.groupNumber = newNumber;
		[self.homeControlAppliances initWithCapacity: 10];
	}
	return self;
}

but can neither add HomeControlAppliances using the method
Code:
- (void) addHomeControlAppliance: (HomeControlAppliance *) newAppliance {
	[self.homeControlAppliances addObject: newAppliance];
}

nor by simply adding an existing array using addObjectsFromArray

Any idea what is wrong? There are no compiler errors or warnings, no console messages...

addObject just destroys the object that I want to add and addObjectsFromArray kills the array.
 

calistra

macrumors newbie
Original poster
Dec 14, 2010
12
0
Singapore
OK - I am an idiot !!!!

Code:
- (id) initGroup: (NSString *) newName  groupNumber: (NSInteger)newNumber {
	self = [super init];
	if (self != nil) {
		self.groupName =  newName;
		self.groupNumber = newNumber;
		[COLOR="Red"]self.homeControlAppliances = [[NSMutableArray alloc] initWithCapacity: 10];[/COLOR]
	}
	return self;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.