Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!