• 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
NSDateFormatter initialization+formatting not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDateFormatter initialization+formatting not working


  • Subject: NSDateFormatter initialization+formatting not working
  • From: Markus Spoettl <email@hidden>
  • Date: Sat, 19 Feb 2011 22:53:30 -0500

Hello,

  I'm not getting why this is not working:

 NSDate *date = [NSDate date];

 NSDateFormatter *df1 = [[NSDateFormatter alloc] initWithDateFormat:@"EEE d" allowNaturalLanguage:NO];
 NSString *s1 = [df1 stringFromDate:date];

s1 ---> @"EEE d";

 NSDateFormatter *df2 = [[NSDateFormatter alloc] init];
 [df2 setDateFormat:@"EEE d"];
 NSString *s2 = [df2 stringFromDate:date];

s2 ---> @"Sat 19"  (on a Saturday the 19th)

I could live with that but the documentation tells me that -init is deprecated in 10.6? Is that really true? When I look at the NSDateFormatter header things look quite differently:

#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
@interface NSDateFormatter (NSDateFormatterCompatibility)

- (id)initWithDateFormat:(NSString *)format allowNaturalLanguage:(BOOL)flag;
- (BOOL)allowsNaturalLanguage;

@end
#endif

Which to me tries to convey that -initWithDateFormat: is deprecated -- not by saying so directly of course.

So who is wrong, docs or header? And why doesn't the -initWithDateFormat: initializer work?

Puzzled
Markus
--
__________________________________________
Markus Spoettl

_______________________________________________

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: NSDateFormatter initialization+formatting not working
      • From: Ken Thomases <email@hidden>
  • Prev by Date: How to use Photo Albums of the landscape mode iphone app
  • Next by Date: Keeping Multiple Identical Tables in Synch - Weird SortDescriptor Binding Problem
  • Previous by thread: Re: How to use Photo Albums of the landscape mode iphone app
  • Next by thread: Re: NSDateFormatter initialization+formatting not working
  • Index(es):
    • Date
    • Thread