Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
iOS Development
Quick question about Date from string
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="SaveMe" data-source="post: 1497279" data-attributes="member: 294134"><p>In my learning book, objective-c for absolute beginners, is written the following example</p><p></p><p>[CODE] </p><p> NSDate *today = [NSDate date];</p><p> NSDate *saleDate = [NSDate dateWithString:@"2011-12-04 04:00:00 -700"];</p><p>[/CODE]</p><p></p><p>The second line is giving me problems in that dateWithString doesn't seem to be a method of the NSDate class. Using google I learned that that is only available on the OS X version of the class.</p><p></p><p>So I resolved it as follows</p><p>[CODE]</p><p> NSDate *saleDate = [[[NSDateFormatter alloc] init] dateFromString:@"2011-12-04 04:00:00 -700"];</p><p>[/CODE]</p><p></p><p>Is this the best and fastest way to do so ?</p></blockquote><p></p>
[QUOTE="SaveMe, post: 1497279, member: 294134"] In my learning book, objective-c for absolute beginners, is written the following example [CODE] NSDate *today = [NSDate date]; NSDate *saleDate = [NSDate dateWithString:@"2011-12-04 04:00:00 -700"]; [/CODE] The second line is giving me problems in that dateWithString doesn't seem to be a method of the NSDate class. Using google I learned that that is only available on the OS X version of the class. So I resolved it as follows [CODE] NSDate *saleDate = [[[NSDateFormatter alloc] init] dateFromString:@"2011-12-04 04:00:00 -700"]; [/CODE] Is this the best and fastest way to do so ? [/QUOTE]
Verification
Name this item. 🍎
Post reply
Forums
macOS & iOS Developer Playground
iOS Development
Quick question about Date from string
Top