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 trial

iOS

Question about a Code Challenge.

I am working on the Code Challenge for Formatting Dates with NSDateFormatter.

Question: Using NSDate create a date object that is 10 days from today and call it 'futureDate'.

Why is the following code not acceptable?

NSTimeInterval futureDate = (60 * 60 * 24) * 10;

NSDate *future = [NSDate dateWithTimeIntervalSinceNow:futureDate];

2 Answers

looks like you are missing an opening parenthesis. That could be causing your problem.

oops that was a typo in this post, but i tried it in the code challenge also and no luck.

I think they want to see a particular syntax even though there are several ways to accomplish.

Are you sure your numbers are right? 960 seems like way too big of a number. NSTimeInterval is seconds I believe. So you should have 60 seconds * 60 to give you seconds in an hour * 24 to give you seconds in a day * 10 to give you seconds in 10 days.

Oh I see now. Your date Object needs to be called *futureDate not *future. Also your unit conversion is not right. Should be 60 * 60 * 24 *10 not 960. But im guessing thats just a typo from typing parenthesis

Sorry that was a typo.

I will try this syntax and see what happens.

NSTimeInterval future = (60 * 60 * 24) * 10; NSDate *futureDate = [NSDate dateWithTimeIntervalSinceNow:future];