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

  • SEARCH
  • Home
  • 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 7554667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:23:57+00:00 2026-05-30T11:23:57+00:00

On this tutorial , the author has these declarations: on .h UIViewController *presentingViewController; …

  • 0

On this tutorial, the author has these declarations:

on .h

UIViewController *presentingViewController;
...

@property (retain) UIViewController *presentingViewController;

on .m

@synthesize presentingViewController;

at some point in code, inside a block, he does:

self.presentingViewController = viewController;

and then

[presentingViewController dismissModalViewControllerAnimated:NO];

I find this very strange. If is is assigning the viewController to self.presentingViewController, should’t it be calling

    [self.presentingViewController dismissModalViewControllerAnimated:NO];

?

I have changed his code to

.h

@property (retain) UIViewController *presentingViewController;

.m

@synthesize presentingViewController = _presentingViewController;

and what I do is:

self.presentingViewController = viewController;

and then

    [self.presentingViewController dismissModalViewControllerAnimated:NO];

the problem is that, self.presentingViewController is nil at this line, even being declared as retain and never being released.

any clues?

thanks

  • 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-05-30T11:23:58+00:00Added an answer on May 30, 2026 at 11:23 am

    Did you remove the instance variable UIViewController *presentingViewController when you added the instance variable UIViewController *_presentingViewController ? If not i would put money on you accidentally using the wrong one at some point.

    Stepping through.. originally you had an instance variable

    UIViewController *presentingViewController;
    

    And from the property syntactic sugar you have the two accessor methods for setting and getting the variable

    - (UIViewController *)presentingViewController;
    - (void)setPresentingViewController:(UIViewController *)val;
    

    at some point in code, inside a block, he does:

    [self setPresentingViewController: viewController]; // uses setter
    

    and then

    [presentingViewController dismissModalViewControllerAnimated:NO]; // uses instance variable
    

    which is fine, but you think it should be

    UIViewController *localPresentingViewController = [self presentingViewController]; // uses getter
    [localPresentingViewController dismissModalViewControllerAnimated:NO];
    

    which is also fine but somewhat unnecessary.

    Then you added a new instance variable:-

    @synthesize presentingViewController = _presentingViewController;
    

    so now you have

    UIViewController *presentingViewController;
    UIViewController *_presentingViewController;
    
    // These now get / set _presentingViewController
    - (UIViewController *)presentingViewController;
    - (void)setPresentingViewController:(UIViewController *)val;
    

    But almost certainly, somewhere you are confusing the two ivars (or you aren’t aware you have two ivars) presentingViewController / _presentingViewController and still have a reference to the presentingViewController ivar, leading you to think your property is nil.

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

Sidebar

Related Questions

Consider this XML file. Note the first Tutorial has an Author child element, and
While reading tutorial for wxWiidgets I saw this Tutorial where author has created 2
I've been following this Symfony tutorial. In some sections it just tells me to
In this tutorial , at the very bottom, the author provides a function type
I read this tutorial about storing images in DB. In the tutorial, the author
I'm trying RubyMine, and watching this tutorial https://www.jetbrains.com/ruby/documentation/ . The author uses there project->new->scaffold
In this blog post the author has suggested the following as the bug fix:
The Gaelyk tutorial provides some nice low level wrappers to the datastore and this
This tutorial on mobileorchard.com uses 2 classes (or 2 sets of .h and .m)
In this tutorial I am reading , Dave Ward creates a page that shows

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.