iOS NSData转int
+ (int) intFromDataReverse:(NSData *)data { int intSize = sizeof(int);// change it to fixe length unsigned char * buffer = malloc(intSize * sizeof(unsigned char)); [data getBytes:buffer length:intSize]; int num = 0; for (int i = intSize - 1; i >= 0; i--) { num = (num << 8) + buffer[i]; } free(buffer); return num; }