Hi.
I'm in the process of (trying) to learn Obj C/Cocoa, and I'm all together new to OOP.
I'm trying to write a simple app that will store to do's. At the moment, all I want it to do is to read data from input text fields (working) and on the press of the create button, instantiate a new todoItem object, with the data stored as instance variables. So essentially every to do item is an object.
My problem is, this all works, but only when there's just one object being instantiated.
For example:
When the 'create to do' button is pressed, an IBAction method runs this code:
then writes its ivars etc..
Obviously, if you press the button again, the exact same code is run, giving an error 'redefinition of itemOne'. Rather than doing this, I need for the object to be dynamically named, so each time the button is pressed objects are instantiated and named automatically eg. itemOne, itemTwo etc.
Is this possible? Perhaps an array of objects?
I hope you understood that longwinded description.
Thanks in advance, Thomas.
I'm in the process of (trying) to learn Obj C/Cocoa, and I'm all together new to OOP.
I'm trying to write a simple app that will store to do's. At the moment, all I want it to do is to read data from input text fields (working) and on the press of the create button, instantiate a new todoItem object, with the data stored as instance variables. So essentially every to do item is an object.
My problem is, this all works, but only when there's just one object being instantiated.
For example:
When the 'create to do' button is pressed, an IBAction method runs this code:
Code:
todoItem *itemOne = [todoItem alloc] init];
then writes its ivars etc..
Obviously, if you press the button again, the exact same code is run, giving an error 'redefinition of itemOne'. Rather than doing this, I need for the object to be dynamically named, so each time the button is pressed objects are instantiated and named automatically eg. itemOne, itemTwo etc.
Is this possible? Perhaps an array of objects?
I hope you understood that longwinded description.
Thanks in advance, Thomas.