• 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: Trouble comparing NSCalendarDates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble comparing NSCalendarDates


  • Subject: Re: Trouble comparing NSCalendarDates
  • From: j o a r <email@hidden>
  • Date: Mon, 15 Nov 2004 10:32:32 +0100


On 2004-11-15, at 10.17, Tito Ciuro wrote:

2) Later, when I need to retrieve it from disk, I call returnedValue = [[[NSCalendarDate alloc] dateWithCalendarFormat:dateData] timeZone:nil]autorelease];

No, that's not right - what do you *really* call?

The data is retrieved from a SQLite database and is a 'const char*'. So I call:


returnedValue = [[[NSCalendarDate alloc] dateWithCalendarFormat:[NSString stringWithUTF8String:data] timeZone:nil]autorelease];

What do you mean with "that's not right"? Why not?

* Always, and only, call an "initXXX" method on the returned value from an alloc method. The init method used also needs to be one of the documented designated initializers for the class!


* -[NSDate dateWithCalendarFormat:timeZone:] is an instance method of NSDate, to convert a NSDate instance into a NSCalendarDate instance. It's not a designated initializer for the NSCalendarDate class!

You should probably do:

NSString *dateStr = [NSString stringWithUTF8String: data];
NSCalendarDate *aDate = [NSCalendarDate dateWithString: dateStr calendarFormat: nil];


j o a r

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Trouble comparing NSCalendarDates
      • From: Tito Ciuro <email@hidden>
References: 
 >Trouble comparing NSCalendarDates (From: Tito Ciuro <email@hidden>)
 >Re: Trouble comparing NSCalendarDates (From: j o a r <email@hidden>)
 >Re: Trouble comparing NSCalendarDates (From: Tito Ciuro <email@hidden>)

  • Prev by Date: Re: Making a window the size of the desktop?
  • Next by Date: Re: How to embed a popup menu in an NSTextField
  • Previous by thread: Re: Trouble comparing NSCalendarDates
  • Next by thread: Re: Trouble comparing NSCalendarDates
  • Index(es):
    • Date
    • Thread