Re: NSDate scope
Re: NSDate scope
- Subject: Re: NSDate scope
- From: John Baldwin <email@hidden>
- Date: Thu, 25 Jun 2009 19:04:13 -0700
I've gone back to my code and tried to reproduce the error. Now I
can't. So I was doing something else stupid that I've since changed.
Now if I do the usual [[NSDate alloc] init] it seems to be behaving as
expected. [NSDate date] can generate the error, but that doesn't
surprise me.
John
On Sunday Jun 21 2:09 PM, at 2:09 PM, Kyle Sluder wrote:
On Sat, Jun 20, 2009 at 4:52 PM, John Baldwin<email@hidden
> wrote:
I declared a (NSDate *) in my .h file.
Where? Inside an @implementation, or as a global variable? If it's a
global variable, you are aware that for every translation unit that
imports your header, you will wind up with a different variable?
Then in my init method, I initialized it to the current date. I tried
various methods, all with the same result:
You're mixing owning methods (alloc, retain) with non-owning methods
(+date). This indicates that you do not understand Cocoa memory
management.
Then, in a method that was called by an NSTimer object, I tried to
use that
date as a reference point. But the debugger showed the variable as
"out of
scope."
Where is this method defined? What object was it being invoked on?
Sounds like you need to do a bit of reading. If you go through the
conceptual docs and still have trouble understanding, post your code
here and we can help you out a bit.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden