Converting between NSData and base64 strings

后端 未结 6 998
野的像风
野的像风 2020-11-29 01:38

What is the easiest and fastest code to do a conversion between NSData and a base64 string? I\'ve read a bunch of solutions at SO and mostly they involve in add

6条回答
  •  不知归路
    2020-11-29 02:05

    You don't need any custom implementation. Creating base64 from NSData is shown in other answers. There is opposite direction. From Base64 string to NSData:

     NSString *base64Encoded = @"some base64 string";
     NSData *nsdataFromBase64String = [[NSData alloc] initWithBase64EncodedString:base64Encoded options:0];
    

提交回复
热议问题