Guest User

Untitled

a guest
Apr 20th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  
  3. missing UITapGestureRecognizer addTarget retain?!
  4. *** -[Test tapDetected:]: message sent to deallocated instance 0x113de4d0
  5.  
  6. **/
  7.  
  8. //  FirstViewController.h
  9. #import <UIKit/UIKit.h>
  10. #import "Test.h"
  11.  
  12. @interface FirstViewController : UIViewController
  13.  
  14. @property (strong, nonatomic) NSMutableArray *meinTest;
  15. @property (strong, nonatomic) Test *meinTest2;
  16.  
  17. @end
  18.  
  19. ### ### ### ### ### ### ### ### ###
  20.  
  21. //  FirstViewController.m
  22. #import "FirstViewController.h"
  23.  
  24. @implementation FirstViewController
  25. @synthesize meinTest;
  26. @synthesize meinTest2;
  27.  
  28. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  29. {
  30.     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  31.     if (self) {
  32.         self.title = NSLocalizedString(@"First", @"First");
  33.         self.tabBarItem.image = [UIImage imageNamed:@"first"];
  34.         self.meinTest = [[NSMutableArray alloc] init];
  35.         self.meinTest2 = [[Test alloc] init];
  36.     }
  37.     return self;
  38. }
  39.                            
  40. - (void)didReceiveMemoryWarning
  41. {
  42.     [super didReceiveMemoryWarning];
  43.     // Release any cached data, images, etc that aren't in use.
  44. }
  45.  
  46. #pragma mark - View lifecycle
  47.  
  48. - (void)viewDidLoad
  49. {
  50.     [super viewDidLoad];
  51.  
  52.     // NO CRASH
  53.     //Test *test = [[Test alloc] init];
  54.     //[self.meinTest addObject:test];
  55.     //UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:test action:@selector(tapDetected:)];
  56.     //[self.view addGestureRecognizer:tap];
  57.    
  58.     // NO CRASH
  59.     //UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self.meinTest2 action:@selector(tapDetected:)];
  60.     //[self.view addGestureRecognizer:tap2];
  61.    
  62.     // CRASH
  63.     //Test *test = [[Test alloc] init];
  64.     //UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:test action:@selector(tapDetected:)];
  65.     //[self.view addGestureRecognizer:tap];
  66. }
  67.  
  68. - (void)viewDidUnload
  69. {
  70.     [super viewDidUnload];
  71.     // Release any retained subviews of the main view.
  72.     // e.g. self.myOutlet = nil;
  73. }
  74.  
  75. - (void)viewWillAppear:(BOOL)animated
  76. {
  77.     [super viewWillAppear:animated];
  78. }
  79.  
  80. - (void)viewDidAppear:(BOOL)animated
  81. {
  82.     [super viewDidAppear:animated];
  83. }
  84.  
  85. - (void)viewWillDisappear:(BOOL)animated
  86. {
  87.     [super viewWillDisappear:animated];
  88. }
  89.  
  90. - (void)viewDidDisappear:(BOOL)animated
  91. {
  92.     [super viewDidDisappear:animated];
  93. }
  94.  
  95. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  96. {
  97.     // Return YES for supported orientations
  98.     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
  99.         return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
  100.     } else {
  101.         return YES;
  102.     }
  103. }
  104.  
  105. @end
Add Comment
Please, Sign In to add comment