Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:57:45+00:00 2026-06-08T01:57:45+00:00

I have been struggling with this problem for a while now, so any help

  • 0

I have been struggling with this problem for a while now, so any help would be greatly appreciated.

Here is the situation: My application has a UIViewController subclass called InitialViewController. This view controller has a UIButton, and when that button is pressed it creates a NSObject subclass called MyEngine. Something like this:

@interface InitialViewController : UIViewController <MyEngineDelegate>
...
@end

@implementation InitialViewController
...
-(IBAction)pressedButton:(id)sender {
    MyEngine *engine = [[MyEngine alloc] init];
    [engine start];
}

Inside start, I present a ViewController (ConflictViewController) modally to get the user’s choice:

@interface MyEngine : NSObject <ConflictViewControllerDelegate>
...
-(void) start;
@end

@implementation MyEngine
...
-(void) start {
        ConflictViewcontroller *cvc = [[ConflictViewController alloc] initWithNibName:@"ConflictViewController" bundle:nil];
        cvc.modalPresentationStyle = UIModalPresentationFormSheet;
        cvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        cvc.delegate = self;
        UIWindow *window = [(MyAppDelegate *) [[UIApplication sharedApplication] delegate] window];
        [[window rootViewController] presentModalViewController:cvc animated:YES];
}
@end

ConflictViewController is really simple. It just waits for the user to decide, and when the user press the button, it send the message to the delegate, and dismiss itself.

-(IBAction)didSelectConflict:(id)sender {
    UISegmentedControl *seg = (UISegmentedControl*) sender;
    [self.delegate didResolveConflictChoice:seg.selectedSegmentIndex];
    [self dismissModalViewControllerAnimated:YES];
}

I’ve checked every connection, all the delegates are working properly.
What is going wrong is:
When MyEngine receives the user’s choice in it’s implementation of didSelectConflict: it cannot continue properly because all of it’s properties have gone null.

When the MyEngine presents the ConflictViewController, the program continues the execution and when start finishes, it goes back to pressedButton: and when this method is closed, the MyEngine object gets released.

What i want to know is if there is way around this ? Has anyone done something like this in another way ?
The question here is: How to get the user’s choice properly when the choice is too complex to use UIAlertView.

Sorry for the long question, I simplified it as much as I could. Thanks for your time, any links, comments, or any kind of help is greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:57:47+00:00Added an answer on June 8, 2026 at 1:57 am

    Why are you initializing MyEngine *engine in the IBAction, if you wish to use a MyEngine object why don’t you make a global declaration in your InitialViewController and just call [engine start] in the IBaction. Then when the delegate method returns the selected index you can apply that to a global int in your initial view controller and continue on your way. Hope that makes sense

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been struggling with this problem, and while something elegant would be preferred any
I have been struggling with this problem for a while now. I have a
I've been struggling with this issue for a while now. I have OpenCart 1.5.2.1
I've been struggling with this issue for a while now. Maybe you can help.
I have been struggling a while with this problem and read a lot but
I have been struggling with this problem for a few days now and I
I have been struggling with this for a while now. I have a Master
I've been stuck on this problem for a while now and have tried my
I've been struggling with this problem for a while now, searching every possible solution.
Okay, I've been struggling with this for a while now. I have a standard

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.