Get last 2 characters of a string?

NSString *code = [state substringFromIndex: [state length] - 2];

should do it