Since your post is so vague, I'll make some guesses to fill in the gaps. Presumably you're trying to measure the amount of real time that the player has spent in a gameplay session? This is as simple as getting the current time when gameplay starts (via whatever time measurement query you'd normally use), getting it again when it ends, and subtracting the previous measurement. Be aware of the difference between wall time and monotonic time, though; presumably you'll want to measure in monotonic time to prevent cheating by altering the system clock during gameplay.

called, like in the tutorial, except that this is an Objective-C method. I also have printf("%lu seconds, %lu nanoseconds\n", tp.tv_sec, tp.tv_nsec), but the values are always 0, even though I have startTime = mach_absolute_time() and endTime = mach_absolute_time() earlier in the code. What could the problem be?

The problem is probably that tp's value is being passed and that value is only being modified locally in mach_absolute_differenceEnd. You need to pass a pointer to a struct timespec, which is what the tutorial does.