I have an application in which I’m trying to implement the LibPusher API for the chat application.
That API is arc enabled and I’ve included that in my nonarc project.
It’s working fine except for some warnings.
Now my problem is i have added a button in the navigation bar like this:
UIButton *btnNext1 =[[UIButton alloc] init];
[btnNext1 setBackgroundImage:[UIImage imageNamed:@"back_btn.png"] forState:UIControlStateNormal];
btnNext1.frame = CGRectMake(100, 100,60, 31);
UIBarButtonItem *btnNext =[[UIBarButtonItem alloc] initWithCustomView:btnNext1];
[btnNext1 addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = btnNext;
[btnNext1 release];
It was working fine and in the action i am doing this:
PusherPresenceEventsViewController *rootView = ( PusherPresenceEventsViewController*)[self.navigationController.viewControllers objectAtIndex:1];
rootView.newmessage =@"";
[self.navigationController popToViewController:rootView animated:YES];
[rootView release];
It’s also working fine for the first two times.
However, on the third time it is giving bad access error.
I’m not understanding where I went wrong, can anybody help me?
and don’t release it .Also release Rootview since you are not allocating it.