NSData from NSKeyedArchiver to NSString

前端 未结 3 1060
悲&欢浪女
悲&欢浪女 2021-02-08 20:20

I\'m trying to convert NSData generated from NSKeyedArchiver to an NSString so that I can pass it around and eventually convert it back to NSData. I have to pass this as a strin

3条回答
  •  温柔的废话
    2021-02-08 21:13

    All you should have to do is something like this:

    NSData *dataFromString = [[NSString stringWithFormat:@"%@", yourString] dataUsingEncoding:NSASCIIStringEncoding];
    

    then to extract the data:

    NSString *stringFromData = [[NSString alloc] initWithData:dataFromString encoding:NSASCIIStringEncoding];
    

提交回复
热议问题