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 7753283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:01:15+00:00 2026-06-01T12:01:15+00:00

I have a costume class called Region and I am using this bit of

  • 0

I have a costume class called Region and I am using this bit of code to initialize the region variable how is that possible that at the end of this bit of code myAppDelegate.provisoryRegion is not nil and region is nil??? isn’t myAppDelegate.provisoryRegion passed by reference to region???
I’m 100% sure that region is nil at the end of this piece of code.

Region *region=myAppDelegate.provisoryRegion;
if (!myAppDelegate.provisoryRegion) {
    myAppDelegate.provisoryRegion=[[Region alloc]init];
}
if (!region){ NSLog(@"region is nil");
}  
  • 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-01T12:01:16+00:00Added an answer on June 1, 2026 at 12:01 pm

    Yes. It must be nil.
    Because you change the object!

    When doing myAppDelegate.provisoryRegion=[[Region alloc]init]; myAppDelegate.provisoryRegion points to a new object (a new address on the heap).

    *region will NOT follow to the new address!

    So *region still point to the NULL address.

    But why you copy your pointer at line 1?
    Why not always use myAppDelegate.provisoryRegion. *region is a unlinked alias of myAppDelegate.provisoryRegion

    Just do at the end in your sample-dummy code and delete line 1:

    if (!myAppDelegate.provisoryRegion){ NSLog(@"region is nil");
    }  
    

    And by the way…

    myAppDelegate.provisoryRegion=[[Region alloc]init];
    

    looks like a memory leak (if your @property is set to retain).

    Fix with:

    myAppDelegate.provisoryRegion=[[[Region alloc] init] autorelease];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that contains a one-to-one mapping. Customer.hbm.xml: <class name=com.asi.shared.Customer table=Customer> <id
I have a Win32 C++ Application using a handful of third-Party DLLs that is
I have a scribbale inkpresenter in my silverlight app that I'm using multiple times
Have some code: using (var ctx = new testDataContext()) { var options = new
Have some dates in my local Oracle 11g database that are in this format:
I have a mapView with only on MKAnnotation, that has a costume image. When
This is code for a costume contest application I'm presently building. There will be
I'm thinking about my website architecture that's using https.. I now have a CDN
have next code: class GameTexture { private: LPDIRECT3DTEXTURE9 texture; unsigned char *alphaLayer; UINT width,
have a look at the code from an xml file where i am using

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.