0

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?

2
  • Add code tags to your question. It's hardly understandable. Commented Jun 26, 2011 at 17:11
  • It looks like the getImageDetailsFromCategory method is overwriting imageDetailsFromCategory. Please post the code for this method Commented Jun 26, 2011 at 17:12

2 Answers 2

2

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];
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.