Quote:
Originally Posted by EJDSlayer
Hi Everyone,
I was wondering if anyone had any comprehensible guides on how to reference a pointer in Objective C / Xcode.
What I'm trying to do:
Say I have a class called Person which stores a name and ID. I have a list of these classes called personList, which contains 20 instances of Person. I then have a function called EditPerson(Person *) which takes in an individual Person for editing and stores them in editP.
How can I make the changes in editP overwrite the data in personList(i).
I can do this no problem in C++ using the following : editP = &personList(i). Is there anything similar I can use in Objective C?
Thanks,
Slayer
|
The equivalent container object in Cocoa is an NSArray.
Look up NSArray and/or NSMutableArray.
An NSArray contains an ordered list of objects.
You'd get object i from an array with coe like this:
Code:
Person* editP;
editP = [personList objectAtIndex: i];