Vibol
Vibol

Reputation: 1168

iOS: Wait for an event of button during the loop

I'm working on a small project in which I need to execute a LOOP to ask questions, and during the LOOP I need to wait for the answer from user before I can perform the next operation.

Any of you could help?

Upvotes: 2

Views: 264

Answers (2)

Reconquistador
Reconquistador

Reputation: 895

You can set all your butons into disabled state:

[myButton setUserInteractionEnabled:false];

After loop is finished, just set it back to true state. This seems to be the easiest possibility.

Upvotes: 0

user23743
user23743

Reputation:

The iPhone's object-oriented framework, Cocoa Touch, already includes the loop you need. There's a class called NSRunLoop that does exactly what you require: it waits for events from the user interface (among other things) and then calls your code to handle the events.

So don't worry about building this loop yourself. Apple has a tutorial that shows how you can build an app that waits for user input and does work based on that input.

Upvotes: 3

Related Questions