开发者

How do I extract a single byte from within a string on iPhone?

In Android, I can extract a single byte from within a string using code like the following:

byte[] arrByte = String.get开发者_JAVA百科Bytes(); . 

If I wanted to do this on the iPhone in Objective-C, how could I accomplish the same task? Additionally, how could I get a byte for a given index in the string?


If you take a look at the NSString reference you will get various methods to get the data from a string. An example is

NSData *bytes = [yourString dataUsingEncoding:NSUTF8StringEncoding];

You can also make use of the method UTF8String

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜