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 Build a Blog Reader iPhone App Adapting Data for Display Formatting Dates with NSDateFormatter

Adapting Data for Display

Challenge # 2

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

My code:

NSTimeInterval secondsPerDay = 60 * 60 * 24 * 10; NSDate *futureDate = [NSDate dateWithTimeIntervalSinceNow:secondsPerDay];

Result:

Bummer! Compilation Error! Please check your syntax and use the code that is provided for you in your implementation.

2 Answers

Stone Preston
Stone Preston
42,016 Points

dont change the secondsPerDay variable. just multiply it by 10 in the method call. also make sure you have the code from task 1 present as well:

NSTimeInterval secondsPerDay = 60 * 60 * 24;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// Add your code below
NSDate *today = [NSDate date];
//multiply the secondsPerDay interval by 10, to get the seconds in 10 days
NSDate *futureDate =  [NSDate dateWithTimeIntervalSinceNow:secondsPerDay * 10];

Thanks bud!