I am trying to initialize an NSMutableArray
with the values of an NSArray
but when I NSLog
the newly created NSMutableArray
all i get is (null
), (null
)... etc
I have no idea why this happening its super frustrating.
I set up myMutableArray
in the header and @synthesize
etc..
then in parserdidend delegate this is what I try to do.
- (void)parserDidEndDocument:(NSXMLParser *)parser
{
if (dataSetToParse == @"ggf"){
//Filter results (ISTOY = T)
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"ISTOY",@"T"];
NSArray *filteredArray = [parsedDataArrayOfDictionaries filteredArrayUsingPredicate:predicate];
NSLog(@"%@", filteredArray); //This prints correct details
[myMutableArray setArray:filteredArray];
NSLog(@"%@", myMutableArray); //This prints (null), (null)... etc
//Use myMutableArray later...
}
That pretty much sums it up.
I guess myMutableArray
is nil?
Also, you can do this:
myMutableArray = [ [ filteredArray mutableCopy ] autorelease ] ;
(don't add the autorelease if you're under ARC)