420Getting current Time with Microseconds

#import <sys/time.h>

struct timeval tv;
gettimeofday(&tv, NULL);
int sec = tv.tv_sec;
int usec = tv.tv_usec;
The system's notion of the current Greenwich time and the current time zone is obtained with the gettimeofday() call, and set with the ettimeofday() call. The time is expressed in seconds and microseconds since midnight (0 hour), January 1, 1970. The resolution of the system clock is hardware dependent, and the time may be updated continuously or in ``ticks.'' If tp is NULL and tzp is non-NULL, gettimeofday() will opulate the timezone struct in tzp. If tp is non-NULL and tzp is NULL, then only the timeval struct in tp is populated. If both tp and tzp are NULL, nothing is returned.

Check out the man page for more info.

87Absolute Time

Several ways:

CFAbsoluteTime abso = CFAbsoluteTimeGetCurrent(); NSTimeInterval inter = [NSDate timeIntervalSinceReferenceDate];

Plus other, more unix intrinsic methods like gettimeofday and mach_absolute_time. The above mentioned methods shall suffice for our needs.

58Delay method execution & passing objects along the way

Specific example. Deselect table cell after a certain time. TableView and indexPath are wrapped into an array and send along to the method for delayed execution.

  • (void)tableView:(UITableView )tView didSelectRowAtIndexPath:(NSIndexPath )indexPath { NSLog(@"User selected row %d\n", [indexPath row] + 1); // actions [self performSelector:@selector(deselectTableCell:) withObject:[NSArray arrayWithObjects:tView, indexPath, nil] afterDelay:0.2f]; }

-(void) deselectTableCell:(NSArray *)array { [[ [array objectAtIndex:0] cellForRowAtIndexPath:[array objectAtIndex:1] ] setSelected:NO]; NSLog(@"deselectTableCell" ); }

In additon to http://codec.trembl.org/35/

35Delay method execution

[self performSelector:@selector(methodName) withObject:nil afterDelay:0.10f];

update: http://codec.trembl.org/58/