i am trying to read jpg file and convert into byte array this is the following code this code works fine with text file but files on image files
// start code
NSString *stringFromFileAtPath = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; if(stringFromFileAtPath == nil){ NSLog(@"Error reading file at path %@\n%@", path, [error localizedFailureReason]); } NSLog(@"Contents:%@", stringFromFileAtPath); NSData *bytes = [stringFromFileAtPath dataUsingEncoding:NSUTF8StringEncoding]; NSLog(@"Bytes:%@", bytes); // end of code
and this is error message i am getting Error Message:Text encoding Unicode (UTF-8) isn’t applicable.
Let me know what is the error i am doing or code to convert jpg file to byte array