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!

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 Diary App Using Core Data Custom UITableViewCell Customizing Table View Cell Appearance

What is the point of dateWithTimeIntervalSince1970 ?

NSDate *date = [NSDate dateWithTimeIntervalSince1970:entry.date];

is used to state the date for the cell.. I was wondering why we used that method.. instead of just printing the date?

What is the exact point of the method, dateWithTimeIntervalSince1970;

1 Answer

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

In THDiaryEntry the date property is defined as NSTimerInterval which is the date represented in seconds. In other words the number of seconds elapsed between the current day and 1/1/1970. To convert the number of seconds into an NSDate object you have to do: NSDate *date = [NSDate dateWithTimeIntervalSince1970:entry.date];

Thanks Amit!! So lucky to be learning from such a great set of instructors! Can't wait to complete the iOS track and then try out the mobile game design & iOS sprite kit tutorial!