One of the properties of ChildClass is childDays. childDays is going to hold a mutable array of DayClass objects. I need to override the init() method to initialize the mutable array. I thought I could do the following:
on init()
continue init()
-- set up mutable array here
end init
At this point I haven’t attempted to set up the mutable array yet. I wanted to make sure this code worked before continuing on. This results in an error when attempting to set up a new ChildClass object:
2013-04-19 16:22:48.051 DayCare Provider[1549:1307] *** -[DayCare_ProviderAppDelegate addChild:]: *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0] (error -10000
What is the best way to initialize the array when a new ChildClass object is created?
EDIT: the init() method override is in the ChildClass class.
on addChild_(sender)
tell current application's ChildClass to set newChild to alloc()'s init()
tell childArrayController to addObject_(newChild) --> the error appears to be happening here
childNameField's selectText_(me)
end addChild_
Before adding the init() override method, this worked as it should. childArrayController is a property of the app delegate that is connected to an array controller in IB. All of the properties of ChildClass are bound to that array controller thru the bindings pane. Up to this point everything has been tested and works as it should (or should I say everything has appeared to work as it should).
The Objective-C method for creating an an instance of a subclass is:
(id) init
{
if (self = [super init])
{
// deal with properties here
}
return self;
}
Your method calls continue init () but returns no value, that’s why you get nil. Try this:
on init()
continue init()
set childDays to current application’s NSMutableArray’s array() return me end init