objective c - ios5 - "EXC_BAD_ACCESS" when clicking button -


i total beginner objective c.

currently try display view in main window. view contains button. reason clicking button xcode throws error.

hopefully can me understand doing wrong.

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions{     self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];     // override point customization after application launch.     self.window.backgroundcolor = [uicolor whitecolor];      btnview *btn = [[btnview alloc] init];     [self.window addsubview:btn.view];             [self.window makekeyandvisible];      return yes; } 

the viewcontroller of button view has action recognizing touch event h file:

- (ibaction)touched:(id)sender; 

and in m file

- (ibaction)touched:(id)sender {     //actions ... } 

by touching button following error:

enter image description here whats wrong?

m file:

enter image description here

h file: enter image description here

i assume have arc enabled project.

when return didfinishlaunchingwithoptions: object assigned btn released since assign local variable defined within method. make btnview *btn strong property of class , should stay around handle button presses. (remember use self.btn in references it.)

(but, i'm curious, why not put button on main view in first place , not worry controller , subviews?)


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -