Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCarmine Sarno
19,660 PointsSwift NSDateFormatterStyle link no longer in documentation.
When Pasan goes to NSDateFormatterStyle timeStyle in the Apple API documentation, he clicks on a link at 5:19 that shows the Swift and Obj-C enums for the style constants (e.g. ShortStyle, MediumStyle, etc.)
That link appears to be gone, along with the Swift NSDateFormatterStyle enum in the documentation as of Xcode 6.1.1.
How would I know what the NSDateFormatterStyle accepts without this in the documentation? Is there some other place I should be looking? The Obj-C constants that are still shown in the documentation do not work in Swift. In other words, if I didn't have this video to tell me that "ShortStyle" and "MediumStyle" are valid constants to pass to the property, where would I find that in the updated documentation? It almost looks like Apple messed up and removed that section without updating the link to the current set of correct style values.
Thanks.
1 Answer
Stone Preston
42,016 Pointsif you view the docs for NSDateFormatter and scroll all the way to the bottom there is a section called Data Types that outlines the various NSDateFormatter styles
The following constants specify predefined format styles for dates and times.
NoStyle Specifies no style.
Equal to kCFDateFormatterNoStyle.
Available in iOS 2.0 and later.
ShortStyle Specifies a short style, typically numeric only, such as “11/23/37” or “3:30 PM”.
Equal to kCFDateFormatterShortStyle.
Available in iOS 2.0 and later.
MediumStyle Specifies a medium style, typically with abbreviated text, such as “Nov 23, 1937” or “3:30:32 PM”.
Equal to kCFDateFormatterMediumStyle.
Available in iOS 2.0 and later.
LongStyle Specifies a long style, typically with full text, such as “November 23, 1937” or “3:30:32 PM PST”.
Equal to kCFDateFormatterLongStyle.
Available in iOS 2.0 and later.
FullStyle Specifies a full style with complete details, such as “Tuesday, April 12, 1952 AD” or “3:30:42 PM Pacific Standard Time”.
Equal to kCFDateFormatterFullStyle.
Available in iOS 2.0 and later.
Carmine Sarno
19,660 PointsCarmine Sarno
19,660 PointsThere it is, thanks!