views:

52

answers:

1

I have a Iphone app with 2 threads. One is listening to the server, and the other is doing UIKit, OpenGl stuff.

I need to run a method that updates a view from the secondary thread thats listening to a server on the main thread that handles the views so I used

performSelectorOnMainThread:@selector"createGuessingView" withObject:nil waitUntilDone:YES

but for some reason, the method never gets executed. Putting a breakpoint or a printf at the beginning of the method shows that its never invoked. Im really stumped here. Ive used performselectoronmainthread in the same program to update text fields and it worked flawlessly.

edit:

Figured it out :) The problem was that the object that I was using performSelectorOnMainThread was set by this thread before the object was initialized (even allocated) in the main thread. Therefore, the reference was pointing to null, and the selector was not getting recognized.

Thanks for the help

+1  A: 

Shouldn't that be:

@selector(createGuessingView)

with no quotes.

--

EDIT (in response to comment)

What the signature for your method? If it's:

- (void)createGuessingView:(id)something

then you should remember the colon, as in @selector(createGuessingView:)

No one in particular
oh yeah, sorry, thats what i have, I just copied it wrong,any other ideas?
MEURSAULT
the signature is -(void) createGuessingView; with no parameters
MEURSAULT
Are you calling the performSelectorOnMainThread method on the object instance that has the createGuessingView method?
No one in particular