Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 12, 2011, 05: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, 05: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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Problem Related to NSTask in Objective C akhilgupta Mac Programming 2 Jun 23, 2011 11:54 AM
Drag and drop mac to mac in parallels or vmware? GrahamW0009 Mac Applications and Mac App Store 2 Jun 5, 2011 10:57 AM
can we create objects Array in objective c? AbhishekApple iPhone/iPad Programming 10 Sep 29, 2010 04:52 PM
How do I read an image from a byte array in Objective C? Knight Rider iPhone/iPad Programming 4 Nov 16, 2009 06:31 AM
delcaring 2d array in Objective C MasterObiWan Mac Programming 6 Feb 3, 2009 04:32 PM


All times are GMT -5. The time now is 08:40 PM.

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

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