0

In iOS, how to present a UIViewController and then wait for its return?

I want to use Objective-C, not Swift.

For example, I want to realize something like the following:

CustomViewController *myDialog;
NSString *dialogReturn;
myDialog = [[CustomViewController alloc] init];
dialogReturn = [myDialog show];
zhoudu
  • 623
  • 8
  • 19
  • you can use delegates and protocols for callbacks. somewhere answered this already ... *looking for link* something like this http://stackoverflow.com/questions/16584930/objective-c-accessing-methods-from-custom-cell/16585079#16585079 – geo Apr 23 '15 at 14:39
  • Yes, I can use delegates and protocols for callbacks. But I need to wait its return so that I can continue the process logic in one method. If I use delegates or protocols to handle that, the process logic will be much more complex. – zhoudu Apr 24 '15 at 04:40
  • Is there any way to do that? – zhoudu Apr 24 '15 at 04:43
  • Try to keep it asynchronous. For sure you can use semaphores or open new threads and wait for them ... But this is not recomanded because you really block the program. Creating a callback method and give all references you need there is the common way – geo Apr 24 '15 at 08:01

0 Answers0