• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDate value set in one method, vanishes when accessed from another
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDate value set in one method, vanishes when accessed from another


  • Subject: Re: NSDate value set in one method, vanishes when accessed from another
  • From: Alex Zavatone <email@hidden>
  • Date: Thu, 19 Apr 2012 14:02:04 -0400

Make it a property so that it doesn't go away, but exists for the whole class.

Check out how to define a property.  There are lots of examples around.

On Apr 19, 2012, at 1:43 PM, The Rhythmic wrote:

> Am sorry to ask such a trivial question. Am a newbie to Objective-C, &
> simply cannot see how to get this working, after having tried several
> possible ways & google'd around for it. Please help!
> My question is simple. I have a class-level NSDate object, which is
> declared outside any method in the class as:
>
> *    NSDate *fromDate;*
>
> Now, within a method, am setting this value to the date from a DatePicker
> as:
>
> *    fromDate = [datePicker date];*
>
> Soon after the above assignment, I print its value into the log & it works
> fine.
>
> *    NSLog(@"From Date: %@", fromDate);*
>
> Now, when I use NSDate's value in another/different method, the value's
> gone! Why is it not persisted across methods in the same class itself? What
> can I do for the value to be accessible across methods?
> _______________________________________________
>
> 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

_______________________________________________

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

  • Follow-Ups:
    • Re: NSDate value set in one method, vanishes when accessed from another
      • From: Uli Kusterer <email@hidden>
References: 
 >NSDate value set in one method, vanishes when accessed from another (From: The Rhythmic <email@hidden>)

  • Prev by Date: Re: Guidelines on using NSJSONSerialization
  • Next by Date: loadNibNamed:owner
  • Previous by thread: NSDate value set in one method, vanishes when accessed from another
  • Next by thread: Re: NSDate value set in one method, vanishes when accessed from another
  • Index(es):
    • Date
    • Thread