Just a quick question. I have an NSArray that is generated in my applicationDidFinishLaunching method, but for some reason the array isn’t being used by other methods and it is saying that it is being unused.
-(void)applicationDidFinishLaunching... {
NSArray* songsArray = [root nodesForXPath:@".//dict/dict/dict" error:nil];
-(id)tableView:(NSTableView *)tableView objectValueForTableColumn... {
for(NSXMLElement* song in songsArray) {
I have declared the variable in the header file also.
Cheers,
Scott
You have declared
songsArrayas a local variable, it’s not visible outsideapplicationDidFinishLaunching.If you have already declared your variable in header, you need to just assign it:
Note on memory management:
If you are not using ARC, you also need to
retainyour array, otherwise it will be autoreleased at the end ofapplicationDidFinishLaunching, and your variable will be pointing to a deallocated memory, and your app will crash.And don’t forget to
releaseit indealloc(again, if you are not in ARC land).