0

I have a tabbar application, the problem is that i need to call a method after a delay of viewDidLoad of the first view but it didn't work (the method is not called) i added the following sample

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self performSelector:@selector(foo) withObject:nil afterDelay:1];

}

-(void)foo
{
    NSLog(@"foo!");
}

the strange thing is that this work with all other tabs view but for some reason it didn't work with the first tab (UITableViewController) any idea??

Thanks

Mahmoud Adam
  • 5,772
  • 5
  • 41
  • 62
  • Are you sure the problem is with "performSelector"? Did you set a breakpoint (or NSLog) into viewDidLoad? Are you sure viewDidLoad is called? Aren't you reimplementing loadView? – kuba Apr 05 '12 at 16:19
  • Does it work in the other method? – Buron Apr 05 '12 at 16:24
  • @JohnSmith yea a'm sure it didn't goes into the method, also i have used timer to call the method and it didn't work also. I don't know why it is not working only in this case – Mahmoud Adam Apr 08 '12 at 08:26

1 Answers1

1

try this....

- (void)viewDidLoad
{
    [super viewDidLoad];
    dispatch_async(dispatch_get_main_queue(), ^{
            [self performSelector:@selector(foo) withObject:nil afterDelay:0.5];
        });

}
vlad sol
  • 99
  • 1
  • 5