Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 12, 2011, 06:49 PM   #1
calistra
macrumors newbie
 
Join Date: Dec 2010
Location: Singapore
Appending to arrays in Objects

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 is offline   0 Reply With Quote
Old Jan 12, 2011, 06:56 PM   #2
calistra
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
Location: 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;
		self.homeControlAppliances = [[NSMutableArray alloc] initWithCapacity: 10];
	}
	return self;
}
calistra is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Please Help with arrays Bigred101 Mac Programming 7 Mar 13, 2014 08:39 PM
Help appending file names? tobefirst Mac Programming 11 Feb 13, 2014 04:40 PM
OpenGL ES: Vertex Buffer Objects and Vertex Array Objects Blakeasd iPhone/iPad Programming 2 Jul 13, 2013 12:24 AM
Airport appending networked Macs' names (2) Goop OS X 0 Apr 18, 2013 01:56 PM
Comparing Two Arrays Ides iPhone/iPad Programming 5 Aug 10, 2012 04:56 PM

Forum Jump

All times are GMT -5. The time now is 02:55 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC