Hello All! I have a (hopefully silly) iPhone programming question. I'm trying to get a string out of an object I created, stored in an AppDelegates NSMutableArray--is there a reason I always get an EXC_BAD_ACCESS error when I try to access (via the appdelegates array, or my controllers copy of it) my NSMutableArray in the cellForRowAtIndexPath method, but NO PROBLEM whatsoever in my ViewDidLoad method? Any thoughts appreciated!
In my "viewDidLoad" method, I have the following code:
appDelegate = (Social_Cost_TrackerAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate setArray];
myCompanies = appDelegate.companies;
NSLog(@"Important Value: %i",[myCompanies count]);
Company *c = [myCompanies objectAtIndex:0];
NSString *me = [c cname];
NSLog(@"2nd Val: %@", me);
In my "cellForRowAtIndexPath" I have the following code:
NSLog(@"Problem Spot--myCompanies-Size: %i",[myCompanies count]);
Company *c = [myCompanies objectAtIndex:0];
NSString *me = [c cname];
NSLog(@"2nd Val: %@", me);
Yet, in the "cellForRowAtIndexPath" method, I get the following error:
Program received signal: “EXC_BAD_ACCESS”.
What am I doing wrong, why can I get a size out of my array, but not an object? I'm a bit stumped here... Thanks for any thoughts! (P.S. I'm not an iPhone/Objective-C developer--just doing a bit of learning here with a side-project).
Below is my debugger output: 2009-11-19 18:42:57.883 Social Cost Tracker[688:207] Important Value: 5 2009-11-19 18:42:57.883 Social Cost Tracker[688:207] 2nd Val: UCBrewers 2009-11-19 18:42:57.885 Social Cost Tracker[688:207] Problem Spot--myCompanies-Size: 5 Program received signal: “EXC_BAD_ACCESS”.