NSDateFormatter initialization+formatting not working
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