views:

30

answers:

2

Hi everyone,

I post this topic because I have a problem with my iPhone application since 3 days. I hope someone can help me because I'm going crazy.

Here is the thing : I fill in an object userXMLData,in the delegate of my application, with a XML Parser. This object contains many NSStrings and a NSMutableArrays which contains objects type Album to.

My problem is : I can display all data of userXMLData with an internal function, but when I'm trying to get the data from the array in my viewController , it doesn't work. I mean, it crashes. It's weird because I can access to the appDelegate.userXMLData.NSString but not of my appDelegate.userXMLData.NSMutableArray

Here is my code :

// Initializaiton in the delegate
userXMLData = [[UserXMLData alloc] init];
userXMLData.myArray = [[NSMutableArray alloc] init];

UserXMLData.h

@interface UserXMLData : NSObject {
    // User Data
    NSString *userId;
    // Content
    NSMutableArray *myArray;
}

@property(nonatomic, retain) NSString *myString;
@property(nonatomic, copy) NSMutableArray *myArray;

@end

//Album.h

@interface Album : NSObject {
    NSString *albumId;
    NSMutableArray *content;
}

@property(nonatomic, retain) NSString *albumId;
@property(nonatomic, retain) NSMutableArray *content;

@end

As I said, I really don't why it crashes. i'm stuck and I cannot continue my application without fixing it.

Thanks in avance !

A: 

Would be able to answer better if you'd show the code where you are trying to access the array and the error you receive on crash, but I'd hazard a guess that you don't have @synthesize myArray in your implementation (.m) file

mbehan
A: 

Enable Zombies by following the instructions here:

http://loufranco.com/blog/files/debugging-memory-iphone.html

This will cause your app to not release any objects and instead cause them to complain to the console if messages are sent to them after they are released.

The most common cause of a crash is releasing too often (or retaining too few times).

Also, running a Build and Analyze can sometimes point these out.

Lou Franco
Yes you were right. I found my mistake, It was just when I wanted to print my data, I released one object, which was the same pointer of my real object...
iLionel