I came across SO posts with incorrect decrement of RC to +0
but none of them where appDelegate Method (as per my knowledge delegate can't be retained )
Following is the code where im having memory leak
iPlayerAppDelegate *appDelegate = (iPlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
int currentTabIndex = appDelegate.tabcontroller.tabBarController.selectedIndex ;
UIButton *btn = (UIButton *)sender;
pageItem* selectedItem = nil;
selectedItem = [appDelegate.pageData.pageItems objectAtIndex:btn.tag];
appDelegate.bStatusValue = FALSE;
if(pageInfo.removeCaptureFile)
{
[appDelegate.commonUtils removeFileFromPath:@"snap.jpeg"];
[appDelegate.commonUtils removeFileFromPath:@"prevSnap.jpeg"];
}
if (appDelegate.launchTimer &&[appDelegate.launchTimer isValid])
{
[appDelegate.launchTimer invalidate];
appDelegate.launchTimer = nil;
// appDelegate.timerFlag = NO;
}
NSArray *viewarray = [self.view subviews];
for(int index=0;index< viewarray.count;index++)
{
UIView *view = [viewarray objectAtIndex:index];
if([view isMemberOfClass:[UITextField class]] || [view isMemberOfClass:[UITextView class]])
{
[view resignFirstResponder];
[view removeFromSuperview];
}
if([view isMemberOfClass:[scrollwinView class]])
{
scrollwinView* scrollView = (scrollwinView*) view;
[scrollView stopTimer];
}
}
if(appDelegate.tabsupport)
{ //to remove the cached view from stack after pressing back
CSNavigationController *navcon= (CSNavigationController*)appDelegate.tabcontroller.tabBarController.selectedViewController;
[navcon removeViewData:pageInfo.screenId];
}
int currentscrid=pageInfo.screenId;
clrScreenId = pageInfo.clrScreenId;
if (appDelegate.connMgr)
{
[appDelegate.connMgr closeHttpStream];
//[connMgr release];
appDelegate.connMgr = nil;
appDelegate.connectionstatus = FALSE;
if(appDelegate.initAnimation.startId == 5)
{
appDelegate.transition = NO ;
[appDelegate readPageData:currentscrid isBack:NO ];
appDelegate.transition = YES;
return ;
}
[appDelegate stopAnimation];
and here is the snapshots of memory leak Method returns an Objective-C object with a +0 retain count and Incorrect decrement of the reference count of an object that is not owned at this point by the caller
why am i getting this leak? am i reassigning appDelegate object?
I have not called release on the return value of that accessor(appDelegate) nor have set it nil, how should i fix this leak?
Thanks in Advance