if i have a NSString as @”aef1230fe”
how can I map it to NSData exacaly so that when doing this:
NSLog("%@",mydata);
gives me the output: <aef1230fe>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unshifting and shifting.
Step one: Get the byte string from your NSString, this is achieved using
-UTF8String.Step two: Read each character in the string, mapping them to their corresponding quartet:
Step three: Shift your quartet up every second time, and or it with the other one:
Step four: Stick your new octet in a buffer to hold the data (this buffer should be malloced to
[dataString length]/ 2).Step five: Turn the buffer into an NSData object.
As mentioned in the comment above, optimizations exist for the
switch; namely the use ofquartet = *iterator - 'a'(or'0', or'A', depending on what segment of the switch you are in).Of course, you might be able to finagle something using the property list serialization API as well (or rather, deserialization).