stupid things I will probably do again

An ongoing series.

  1. NSString has an intValue method and a longLongValue method, but it doesn't have a longValue method. NSValue has a longValue method, which means that this will throw an exception at runtime rather than being flagged by the compiler:
NSArray *items = [aString componentsSeparatedByString:aSeparator];  
long value = [items[0] longValue];  

stupid things I will probably forget again

  1. You can add a gesture recognizer to a UIImageView, but it won't do anything until you set userInteractionEnabled on.

  2. NSString has a dataUsingEncoding: method, but NSData doesn't have a stringUsingEncoding: method. You have to use [[NSString alloc] initWithData:encoding:.

  3. [tableView indexPathForCell:cell] might work some of the time.
    [tableView] will work all of the time.