Having:
@interface MyClass : NSObject {
NSString *name; // retained and synthesized
NSString *address; // retained and synthesized
}
I'm creating an array:
NSMutableArray *myArray; // retained and synthesized
Filling it with several MyClass objects:
MyClass *kat = [MyClass new];
kat.name = @"somestring";
kat.address = @"someotherstring"
[myArray addObject:kat];
[kat release];
How can I get object at some index? The code below keeps giving me null but it should illustrate what I need..
MyClass *obj = (MyClass*)[myArray objectAtIndex:5];
NSLog(@"Selected: %@", obj.address); // = null :(
Is it something wrong with casting or I'm forgetting about something?
NSMutableArray *myArray, or only declared it? You'll need a line like[[NSMutableArray alloc] init]somewhere.