In my code I construct a hex NSString first and then use the utility function below to convert it to NSData for transmission. For example:
+ (NSData *)convert