我遇到了 SO 帖子,incorrect decrement of RC to +0
但没有一个是appDelegate 方法(根据我的知识,委托不能被保留)
以下是我有内存泄漏的代码
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];
这是内存泄漏的快照方法返回一个带有+0保留计数的Objective-C对象,并且调用者此时不拥有的对象的引用计数不正确递减
为什么我得到这个泄漏?我要重新分配 appDelegate 对象吗?
我没有在那个访问器(appDelegate)的返回值上调用release,也没有将它设置为nil,我应该如何修复这个泄漏?
提前致谢