1
Chit-Chat / Re: So you want to be a Game Designer ?
« on: January 14, 2013, 04:00:28 am »
Awesome, thanks! Never stumbled upon it before.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//Setting TimeTemp to current date.
[dateFormatter setDateFormat:@"yyyy-MM-dd-hh-mm-ss"];
tempHolder = _TempTime;_TempTime = [dateFormatter stringFromDate:[NSDate date]];
[_TempTime retain];
[tempHolder release];
//Checking if TempTime2 is "EMPTY" and setting it to current time if true.
if([self sameAs:_TempTime2 two:@"EMPTY"])
{
tempHolder = _TempTime2;_TempTime2 = _TempTime;
[_TempTime2 retain];
[tempHolder release];
}
//Transforming strings to NSDate format.
[dateFormatter setDateFormat:@"yyyy-MM-dd-hh-mm-ss"];
NSDate *startDate = [dateFormatter dateFromString:_TempTime2];
NSDate *endDate = [dateFormatter dateFromString:_TempTime];
//Executing calendar function to get proper time difference.
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorianCalendar components:NSSecondCalendarUnit
fromDate:startDate
toDate:endDate
options:0];
//Retrieving time difference in seconds.
NSInteger seconds = [components second];
//Uncomment if you want to see Debug info.
//NSLog(@"NSInteger value :%d", seconds);
//Setting TimeNum to dime difference
float _TempNum = (float)(seconds);
[dateFormatter release];