Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>how do I convert it to a byte array as in Windows and manipulate it. I searched stack overflow and found this piece of code</p> </blockquote> <p>Take a look at NSString's <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/getCString%3amaxLength%3aencoding%3a" rel="nofollow"><code>-getCString:maxLength:encoding:</code></a> method, which will interpret the string using the encoding you specify and copy the result into the buffer you provide. You can then manipulate it however you like. There are one or two other methods along similar lines, but that one should get you started.</p> <p>To convert back to a NSString, you can use <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/clm/NSString/stringWithCString%3aencoding%3a" rel="nofollow"><code>+stringWithCString:encoding</code></a>, <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/clm/NSString/stringWithUTF8String%3a" rel="nofollow"><code>+stringWithUTF8String:</code></a>, <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/clm/NSString/stringWithCharacters%3alength%3a" rel="nofollow"><code>+stringWithCharacters:length:</code></a>, or the <code>-init...</code> versions of any of those.</p> <blockquote> <p>Also, when adding values to bytes in array in windows, if the value goes beyond 256, it stays within 256 automatically (say, 115 + 300, it is stored as 159), this eases my process of subtracting the value and getting the original value back. How can this be done in the iOS app.</p> </blockquote> <p>It's not the operating system that determines that sort of behavior, but the language. Objective-C's behavior on this respect is just like that of C, C++, and probably C# -- if you're working with a type like <code>unsigned char</code>, values will be constrained to 0..255. After all, you can only fit so many values in 8 bits.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload