Reputation: 4728
I declared a NSMutable array and assigned some values to it.
.h
NSMutableArray *imageDetailsFromCategory;
@property (nonatomic, retain) NSMutableArray *imageDetailsFromCategory;
.m
@synthesise imageDetailsFromCategory
in ViewDidLoad:
imageDetailsFromCategory = [[NSMutableArray alloc]init];
//assigning object to Array..working fine.showing two images.
imageDetailsFromCategory = [self getImageDetailsFromCategory:generatedString];
Now my app is loading... I am doing some UI changes with the array. However I want to pass this array on another button click to another class. But when click event is triggered the array shows 0x76779e0"{(int)$VAR Count}
like this in the same class I declared the arry. I can't get the array count after the button click.
Can any one tell me how can I access my array. What is the problem?
Upvotes: 0
Views: 127
Reputation: 32681
You are overriding your imageDetailsFromCategory
variable that you alloc'd in the first line with your second line.
So imageDetailsFromCategory = [[NSMutableArray alloc] init]
creates a mutable array… but imageDetailsFromCategory = [self getImageDetailsFromCategory:generatedString];
replaces the previously alloced mutable array with a brand new object.
THat's as if you did int i=5;
then i = [self someMethod];
: the value 5 would be lost.
Upvotes: 0
Reputation: 4197
The method [self getImageDetailsFromCategory:generatedString];
I think returns a autoreleased
array. Try using the proper setter for retaining it, like
self.imageDetailsFromCategory = [self getImageDetailsFromCategory:generatedString];
Upvotes: 2