Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Denvildaste

macrumors newbie
Original poster
Apr 7, 2010
8
0
Hello,

I have a simple login form in my application, when I press login I simply want the login button to get disabled.

When I press the button I call a function, inside it I disable the button and call a NSInvocationOperation that invokes the login code, that works so far.

The login code loads a new view controller on success, that view controller is technically running in the operation that I spawned and not the main thread, I don't know if that's the best practice but I don't mind much, my problem is that I can't start any timers from my new view controller (the timer code works fine if I load the login page from the main thread, but if I do that I can't disable the login button until the login code is finished).

Any ideas how to solve this? or any better implementations? any help would be appreciated
 
You should only update the UI on the main thread. Anything else is unsupported and may even crash. There is the well documented performSelectorOnMainThread:withObject:waitUntilDone: method which is perfect for this.


Thanks man that was an elegant solution, bounced my code flow back into the main thread and everything worked great, right now I'm making sure the thread won't be editing any part of the UI.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.