【发布时间】:2009-08-10 07:24:28
【问题描述】:
我在 uitableviewcell 的 didselectrow 方法上使用这个
[NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil];
它工作正常,但它在 gdb 中显示这样的错误
2009-08-10 12:45:01.313 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): 类 UIView 的对象 0x458200 自动释放,没有适当的池 - 只是泄漏 堆栈:(0x907d7adf 0x906e41f2 0x29a6 0x906eabad 0x906ea754 0x93e2d6f5 0x93e2d5b2) 2009-08-10 12:45:01.314 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): NSCFString 类的对象 0x2a0e8 自动释放,没有适当的池 - 只是泄漏 堆栈:(0x907d7adf 0x906e41f2 0x30ad10b0 0x30ad12e6 0x29c5 0x906eabad 0x906ea754 0x93e2d6f5 0x93e2d5b2)
我也试过计时器,但没用
我的定时器代码是这个
MyTimer = [NSTimer timerWithTimeInterval:0.01 target:self 选择器:@selector(showMyWaitView) userInfo:nil repeats:NO]; [[NSRunLoop mainRunLoop] addTimer:MyTimer forMode: NSDefaultRunLoopMode];
我也试过了
MyTimer = [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
[NSThread sleepForTimeInterval:0.03];
这是我的 showMyWaitView 方法
-(void)showMyWaitView
{
[self.view addSubview:MyWaitViewObj.view];
}
这是我做的 selectrow 方法
if(MyWaitViewObj==nil)
{
MyWaitViewObj = [[MyWaitViewController alloc] initWithNibName:@"MyWaitView" bundle:nil];
}
//MyTimer = [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
MyTimer = [NSTimer timerWithTimeInterval:0.01 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:MyTimer forMode: NSDefaultRunLoopMode];
[NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil];
//[NSThread sleepForTimeInterval:0.03];
[indexTableView deselectRowAtIndexPath:indexPath animated:YES];
categoryId = [[listOfCategoryId objectAtIndex:indexPath.section] intValue];
categoryType=[[listOfCategoryType objectAtIndex:indexPath.section] intValue];
[self getFlashCard:categoryId];
flashcardid = [[flashCardsId objectAtIndex:indexPath.row] intValue];
//NSLog(@"%s %d %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, __FUNCTION__);
if(MyPageViewControllerObj==nil)
{
MyPageViewController *vController= [[MyPageViewController alloc] initWithNibName:@"MyPageView" bundle:[NSBundle mainBundle]];
self.MyPageViewControllerObj=vController;
[vController release];
}
//
MyPageViewControllerObj.sessionid=sessionid;
MyPageViewControllerObj.categoryID = categoryId;
MyPageViewControllerObj.flashcardIdforcount = flashcardid;
MyPageViewControllerObj.categoryType=categoryType;
MyPageViewControllerObj.indexViewControllerobj=self;
[self.navigationController pushViewController:MyPageViewControllerObj animated:YES];
[MyPageViewControllerObj refreshMyPageView];
//[MyPageViewControllerObj release];
NSLog(@"My MySlidingController View Ka retain Count=%d",[MyPageViewControllerObj retainCount]);
[MyWaitViewObj.view removeFromSuperview];
如何使用计时器显示活动指示器请帮助我或告诉我这个 gdb 错误会导致应用程序崩溃
【问题讨论】:
标签: objective-c iphone gdb nstimer nsthread