Convert string to mutable data - objective c [dupl

2019-10-02 15:13发布

This question already has an answer here:

How to convert a string into mutable data in objective c

2条回答
虎瘦雄心在
2楼-- · 2019-10-02 15:52

You can convert NSString to NSData by using

NSString* str = @"mystring";
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSMutableData *yourdata = [data mutableCopy];

hope it helps you :)

查看更多
Animai°情兽
3楼-- · 2019-10-02 15:53

You can do something like,

NSString *str = @"any string";

NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];

NSMutableData *mutableData = [data mutableCopy];;

Hope this will help :)

查看更多
登录 后发表回答