How to convert unmanaged to NSData?

后端 未结 2 1569
终归单人心
终归单人心 2021-01-12 19:06

I need to convert my Objective-C to Swift to get an image of a contact from the Address Book. But I get an error with for cast from CFData to NSData

2条回答
  •  时光说笑
    2021-01-12 19:34

    if let imgData = ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatOriginalSize)?.takeUnretainedValue() {
       if let image = UIImage(data: imgData) {
          //Here's your UIImage
       }
    }
    

提交回复
热议问题