Guest User

Untitled

a guest
Aug 21st, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. NSArray is getting an EXC_BAD_ACCESS
  2. NSString *text0;
  3. ...
  4. NSString *text123;
  5.  
  6. NSMutableArray *fortunesArray;
  7. }
  8.  
  9. @property(nonatomic,retain) NSMutableArray *fortunesArray;
  10.  
  11. @property (nonatomic, retain) IBOutlet UIWindow *window;
  12.  
  13. @property (nonatomic, retain) IBOutlet AppViewController *viewController;
  14.  
  15. @end
  16.  
  17. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  18. {
  19. // Override point for customization after application launch.
  20.  
  21. text0 = @"Text here";
  22. ...
  23. text123 = @"Text here";
  24.  
  25. self.fortunesArray = [NSMutableArray arrayWithObjects:text0,text1,text2,text3,text4,text5,text6,text7,text8,text9,text10,text11,text12,text13,text14,text15,text16,text17,text18,text19,text20,text21,text22,text23,text24,text25,text26,text27,text28,text29,text30,text31,text32,text33,text34,text35,text36,text37,text38,text39,text40,text41,text42,text43,text44,text45,text46,text47,text48,text49,text50,text51,text52,text53,text54,text55,text56,text57,text58,text59,text60,text61,text62,text63,text64,text65,text66,text67,text68,text69,text70,text71,text72,text73,text74,text75,text76,text77,text78,text79,text80,text81,text82,text83,text84,text85,text86,text87,text88,text89,text90,text91,text92,text93,text94,text95,text96,text97,text98,text99,text100,text101,text102,text103,text104,text105,text106,text107,text108,text109,text110,text111,text112,text113,text114,text115,text116,text117,text118,text119,text120,text121,text122,text123,nil];
  26.  
  27.  
  28. self.window.rootViewController = self.viewController;
  29. [self.window makeKeyAndVisible];
  30. return YES;
  31. }
  32.  
  33. -(IBAction)ganjaButton:(id)sender{
  34. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  35.  
  36. int pressCount;
  37. NSString *display;
  38. if(pressCount%2==0){
  39. [sender setBackgroundImage:[UIImage imageNamed:@"nug2.png"] forState:UIControlStateNormal];
  40. display = [[NSString alloc] initWithFormat:@"%@",[appDelegate.fortunesArray objectAtIndex:40]];
  41. }
  42. else{
  43. [sender setBackgroundImage:[UIImage imageNamed:@"nug1.png"] forState:UIControlStateNormal];
  44. display = [[NSString alloc] initWithFormat:@"%@",[appDelegate.fortunesArray objectAtIndex:44]];
  45. }
  46. pressCount++;
  47.  
  48. label.text = display;
  49. [display release];
  50.  
  51. NSString *filePath = [bundle pathForResource:@"textStrings" ofType:@"plist"];
  52.  
  53. self.fortunesArray = [NSMutableArray arrayWithObjects:text0, text1, text2, nil];
Add Comment
Please, Sign In to add comment