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

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

NSTimeInterval secondsPerDay = 60 * 60 * 24 *10; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSDate *today = [NSDate date]; NSDate *futureDate = [NSDate dateWithTimeIntervalSinceNow:secondsPerDay];

Please correct me if I am wrong!

1 Answer

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Sanghmitra Banerjee ,

You might want to use an additional NSTimeInterval variable for that - just for the challenge to pass.

So the complete solution for Challenge task 2 of 4 "Using NSDate create a date object that is 10 days from today and call it 'futureDate'." e.g. could be like:

NSTimeInterval secondsPerDay = 60 * 60 * 24;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// Add your code below
NSDate *today = [NSDate date];
NSTimeInterval future = (60 * 60 * 24) * 10;
NSDate *futureDate = [NSDate dateWithTimeIntervalSinceNow:future];
Daniel Templin
Daniel Templin
5,293 Points

And what I went with, which still cut down on variables being created, was to create "futureDate" with the calculations hinging off of the "secondsPerDay". It looked a little like:

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

Slightly less clutter for the same calculations.