I have a binary file (file.bin) in the resources folder, I want to read it and show it as binary. The idea its to put the binary information into a array, but, at first, I'm trying to show it in a UILabel, like that:
` NSData *databuffer; NSString *stringdata;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"bin"];
NSData *myData = [NSData dataWithContentsOfFile:filePath];
if (myData) {
stringdata = [NSString stringWithFormat:@"%@",[myData description]];
labelfile.text = stringdata;
}
`
But it shows the data in HEX. How can I do it in binary to put it in a NSMutableArray? Thanks.
I don't know if there is anything native that does that but I can propose a workaround solution. Why don't you do your own function that does the conversion. Here is my example:
In the place you get the Hex values:
The workaround function:
Hope this helps!