views:

344

answers:

2

i m using this on uitableviewcell's didselectrow method

[NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil];

it works fine but it shows error in gdb like this

2009-08-10 12:45:01.313 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): Object 0x458200 of class UIView autoreleased with no pool in place - just leaking Stack: (0x907d7adf 0x906e41f2 0x29a6 0x906eabad 0x906ea754 0x93e2d6f5 0x93e2d5b2) 2009-08-10 12:45:01.314 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): Object 0x2a0e8 of class NSCFString autoreleased with no pool in place - just leaking Stack: (0x907d7adf 0x906e41f2 0x30ad10b0 0x30ad12e6 0x29c5 0x906eabad 0x906ea754 0x93e2d6f5 0x93e2d5b2)

i have also tried timer but that didn't work

my Timer Code is This

MyTimer = [NSTimer timerWithTimeInterval:0.01 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO]; [[NSRunLoop mainRunLoop] addTimer:MyTimer forMode: NSDefaultRunLoopMode];

i have also tried this

MyTimer = [NSTimer scheduledTimerWithTimeInterval:0.0001 target:self selector:@selector(showMyWaitView) userInfo:nil repeats:NO];

[NSThread sleepForTimeInterval:0.03];

and this is my showMyWaitView method

-(void)showMyWaitView
{
[self.view addSubview:MyWaitViewObj.view];
}

here is my did selectrow method

  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];

how do i show activity indicator using timer please help me or tell me will this gdb error cause application crash

+1  A: 

If you're setting up a Thread, you need to set up the run loop and create an NSAutoreleasePool for that thread as well, which is released when the Thread exits. The problem is you're doing neither when you fire off your selector like that. Your showMyWait should set up the release pool, from NSThread documentation

For non garbage-collected applications, the method aSelector is responsible for setting up an autorelease pool for the newly detached thread and freeing that pool before it exits. Garbage-collected applications do not need to create an autorelease pool.

AlBlue
could you please modify my code
Rahul Vyas
@Rahul - Modifying your code for you isn't going to help you learn. You've been told what you need to do and there is more information on that in the documentation, which was kindly linked for you.
Jasarien
thanks sir your answer worked. Getting that in auto release pool worked
Rahul Vyas
A: 

All UI updates must be made on the main thread.

Corey Floyd