Search Results

Search found 2 results on 1 pages for 'jubu1324'.

Page 1/1 | 1 

  • Pause code execution until UIAlertView button is pressed?

    - by JuBu1324
    One of my methods sends a message to an object (what do you know about that), and expects a BOOL for an answer. However, BOOL answer it is expecting is based on the answer to a UIAlertView created in the receiving object's method. However, the code doesn't pause while waiting for the user to answer the UIAlertView. My problem is: how do I use -alertView:clickedButtonAtIndex in the method's return value? Here's the code the message runs (in this construction, I was expecting navigateAwayFromTab to change based on the user input in the UIAlertView, but it never gets a chance): - (BOOL)readyToNavigateAwayFromTab { NSLog( @"message received by Medical View"); navigateAwayFromTab = NO; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Navigate Away From Tab?" message:@"Navigating away from this tab will save your work." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil ]; [alert show]; [alert release]; return navigateAwayFromTab; } #define CANCEL 0 #define OK 1 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if( buttonIndex == OK ) navigateAwayFromTab = YES; } I've been reading up on the modal UIAlertView debate, and I agree with apple's implementation - at lest as the rule. However, in this case I don't see any way of solving the problem by putting code in -alertView:clickedButtonAtIndex because I don't need to run code based on the UIAlertView, I just need to read the response. Any suggestions on how I can reach my gaol? I've tried a while loop after [alert show] already, but then the alert doesn't even show then, and for a number of reasons I can't use -viewWillDisapear.

    Read the article

  • Pass a class as a parameter?

    - by JuBu1324
    I have been lead to believe that it is possible to pass a class as a method parameter, but I'm having trouble implementing the concept. Right now I have something like: - (id)navControllerFromView:(Class *)viewControllerClass title:(NSString *)title imageName:(NSString *)imageName { viewControllerClass *viewController = [[viewControllerClass alloc] init]; UINavigationController *thisNavController = [[UINavigationController alloc] initWithRootViewController: viewController]; thisNavController.tabBarItem = [[UITabBarItem alloc] initWithTitle: title image: [UIImage imageNamed: imageName] tag: 3]; return thisNavController; } and I call it like this: rootNavController = [ self navControllerFromView:RootViewController title:@"Contact" imageName:@"my_info.png" ]; What's wrong with this picture?

    Read the article

1