Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ulquiorra

macrumors member
Original poster
Jun 17, 2009
38
0
Hello everyone , I'm still new to iPhone programming and objective c so bear with me.
I would like to access my array from one to another class.
How can I realize this.
This is my situation :

I'm reading an xml file and my parser saves a lot in an array. I would like to assign the values from this array to an object.

ex.
Code:
[ aLabel setTitle: myarray objectAtIndex:2] forState:UIControlStateNormal];

myarray would be the array in my parserclass.

Does anyone know how to do this( or perhaps know an easier way ) ?
Again i'm new so if someone offers an explanation a little code sample would be nice:D
thanks in advance.
 
Hi,

I'm not sure i understand your issue, but here's something that may help :

Let say you have class A and class B, class A wants to access the array of class B.

First thing, class B must provide some ways for the outside world to access its array. You can do it in 2 ways :
- define a property :

@interface B {
......
NSArray *myArray;
}
@property NSArray *myArray;
......

@implementation B
@synthesize myArray;

- provide a method to return myArray.


Second thing, A must have reference to B.


Hope this helps.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.