I'm having some problems with this.
I want to take an NSString and convert it to an integer array of only 0,1 values that would represent the binary equivalent of an ascii string.
So for example say I have the following
NSString *string = @"A"; // Decimal value 65
I want to end up with the array
int binary[8] = {0,1,0,0,0,0,0,1};
then given that I have the binary integer array, how do I go back to an NSString?
I know that NSString stores characters as multiple bytes but I only want to use ASCII. I tried using,
NSData *data = [myString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
to convert my string to ascii, but I'm still having a lot of issues. Can someone please help me out? :)
*Note this code leaves out the extra requirement of storing the bits into an integer array in order to be easier to understand.
Now I guess I've just got to filter out any non ascii characters from my NSString before I do these steps.
Convert NSString to Integer:(got it from link Ben posted )
then pass it to function below :