1. 添加通讯录联系人
/**
添加联系人
*/
+ (void)addContact:(CNContact *)contact {
// 创建联系人请求
CNSaveRequest *saveRequest = [[CNSaveRequest alloc] init];
[saveRequest addContact:[contact mutableCopy] toContainerWithIdentifier:nil];
// 写入联系人
CNContactStore *store = [[CNContactStore alloc] init];
[store executeSaveRequest:saveRequest error:nil];
}
2. 添加图片到图库中
let image = UIImage.init(data: successObject as! Data)!
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAsset(from: image)
}, completionHandler: { (isCompleted, error) in
if error != nil {
myPrint(message: "image save error")
}
})
3. 添加视频到图库中
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: successObject as! URL)
}, completionHandler: { (isCompleted, error) in
if error != nil {
myPrint(message: "video save error")
}
})