NSThread and callBack

Discussion in 'iOS Programming' started by sujithkrishnan, May 12, 2009.

  1. sujithkrishnan macrumors 6502

    Joined:
    May 9, 2008
    Location:
    Bangalore
    #1
    Hi all,

    I am having a util class and some method associated with it.

    I am calling the someMethod in a detached thread using code shown below


    Code:
    
    [B]In AppDelegate.m[/B]
    
    [NSThread detachNewThreadSelector:@selector(someMethod:) toTarget:utilClassObject  withObject:nil];
    
    After the successful completion of thread i want to make a callback to method in AppDelegate class. But the below method (which i am supposed to use) is not having parameter to specify the target.

    Below code will look for callBackMethod in utilClass
    Code:
    [B]In utilclass.m[/B]
    [B]In someMethod[/B]
    [self performSelectorOnMainThread:@selector(callbackMethod:) withObject:nil waitUntilDone:NO];
    
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    performSelectorOnMainThread:withObject:waitUntilDone: is called on the target object where the selector exists, so "self" is the target. Maybe it should be something like:

    Code:
    [[b]delegate[/b] performSelectorOnMainThread:@selector(callbackMethod:) withObject:nil waitUntilDone:NO];
     

Share This Page