How to convert CFDataRef into NSData?

前端 未结 2 1424
星月不相逢
星月不相逢 2020-12-30 02:28

How to convert CFDataRef into NSData ?

I have CFDataRef and I want to convert it into NSData. I am not getting how to do this.

anyone help me..



        
相关标签:
2条回答
  • 2020-12-30 02:53

    It's toll-free bridged, so you just have to cast it.

    NSData *myData = (NSData *)myCFDataRef;
    
    0 讨论(0)
  • 2020-12-30 02:55

    As @KrisMarkel said, you just have to transfer ownership to ARC like so:

    Like so to transfer ownership:

    NSData* data1 = (__bridge_transfer NSData*) data;
    

    else to use the reference without transferring ownership:

    NSData* data2 = (__bridge NSData*) data;
    
    0 讨论(0)
提交回复
热议问题