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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:32:54+00:00 2026-05-11T20:32:54+00:00

Having problems with out of scope for NSDate in an iphone app. I have

  • 0

Having problems with out of scope for NSDate in an iphone app.

I have an interface defined like this:

@interface MyObject : NSoObject {
    NSMutableArray  *array;
    BOOL        checkThis;
    NSDate      *nextDue;

}

Now in the implementation I have this:

-(id) init
{
    if( (self=[super init]) ) {
        checkThis = NO;
        array = [[NSMutableArray alloc] init];
        nextDue = [[NSDate date] retain];


                NSDate *testDate = [NSDate date];
    }
    return self;
}

Now, if I trace through the init, before I actually assign the variables checkThis shows as boolean. array shows as pointer 0x0 because it hasn’t ben assigned. But the nextDue is showing as ‘out of scope’. I don’t understand why this is out of scope but the other variables aren’t.

If I trace through the code until after the variables are assigned, array now shows as being correctly assigned but nextDue is still out of scope. Interestingly, the testDate variable is assigned just fine and the debugger shows this as a valid date.

Further interesting point is if I move the mouse over the testDate variable while I am debugging, it shows as an ‘NSDate *’ type which I would expect since that’s its definition. Yet the nextDue, which to me is defined the same way is showing as a ‘_NSCFDate *’.

Any googling I did on the subject said that the retain is the problem, but its actually out of scope before I even try to assign the variable.

However, in another class, the same definition for NSDate work ok. It shows as nil before a value is assigned to it. Arghhh

  • 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-11T20:32:54+00:00Added an answer on May 11, 2026 at 8:32 pm

    I also posted this question in the iphone dev forum. The answer I got there seems to be correct. Basically, its just a funny thing in the debugger. Actually, not so funny considering the amount of time I spent on it. When I use NSLog to view the result of the variable, it does actually show the value correctly.

    The NSDate versus _NSCFDate issue is as Stephen said, a toll-free bridge.

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

Sidebar

Related Questions

I am having some problems figuring out this issue. I have a server that
I am having a few problems with how I've structured my App. I have
This seems like a straightforward task, but I'm having trouble figuring out the rails
I'm having some problems figuring out how to organise data pulled off XML in
Just trying out Hibernate (with Annotations) and I'm having problems with my mappings. I
Currently i am having some problems with getting some data out of a DataTable
I'm really having a problem finding out how to fix this. I cannot seem
I'm having a problem with getting this code to print out to file due
Hope someone can help me out with this problem I am having. I just
I have a little newbie problem that I cannot figure out, I am having

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.