AlexMath
AlexMath

Reputation: 647

NSMutable Array won't alloc, remains nil

A XML parser is trying to alloc its delegate's NSMutable array called masterCodeList. From the following code, you'll see that this fails. (I am a total newbie.)

if (dataController.masterCodeList == nil){

    dataController.masterCodeList =[[NSMutableArray alloc] init];
    if (dataController.masterCodeList == nil) {
        NSLog(@"the init of the mutable array did NOT work");
    }
}

I get the the init of the mutable array did NOT work message every time. I am importing the dataController header.

#import "CodeDataController.h"

I am getting no other error message, the parser is parsing fine and the app is running smoothly without content.

Thanks in advance.

Upvotes: 0

Views: 127

Answers (2)

WhatsGoud
WhatsGoud

Reputation: 41

could you post your implementation of the dataController object in this class, and its attributes from the other class?

you also may want to try using the isEqual method instead of == nil.

Upvotes: 0

KaosDG
KaosDG

Reputation: 466

What does your declaration of masterCodeList look like? Is it a property, and is it synthesized, or are you making your own setter/getter?

An alternative would be to try using an intermediate placeholder, ie:

NSMutableArray *temp = [[NSMutableArray alloc] init];
[dataController setMasterCodeList:temp];

and see if that sets your array correctly.

(note: that code may or may not have leaks)

Upvotes: 1

Related Questions