Convert NSString into byte array iphone

前端 未结 3 706
滥情空心
滥情空心 2021-01-19 04:10

Hi I want to convert the NSString into Byte array.

if I have string like \"Hello\" then it convert into byte like this {65,23,56,56,56}.

thanks

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-19 05:05

    From the docs:

    "Gets a given range of characters as bytes in a specified encoding."

    - (BOOL)getBytes:(void *)buffer maxLength:(NSUInteger)maxBufferCount usedLength:(NSUInteger *)usedBufferCount encoding:(NSStringEncoding)encoding options:(NSStringEncodingConversionOptions)options range:(NSRange)range remainingRange:(NSRangePointer)leftover
    

提交回复
热议问题