This line is problematic, since count returns a NSUInteger, count - 1 yields 18446744073709551615 on a 64 bit processor.
count
NSUInteger
count - 1