ios - swift : Issue with saving contact with AddressBook - (Xcode6-Beta5)

标签 ios swift ios8 abaddressbook

当我尝试存储新联系人的电话号码时,在下面的第一步中

let multiPhone : ABMutableMultiValueRef = ABMultiValueCreateMutable(kABMultiStringPropertyType)

给予

'int' is not convertible to 'ABPropertyType'

可能是,

func ABMultiValueCreateMutable(type: ABPropertyType) -> Unmanaged<ABMutableMultiValueRef>!

接受声明为 typealias ABPropertyType = UInt32 的 ABPropertyType,但是,

var kABMultiStringPropertyType: Int { get }

返回 Int 而不是 UInt32。

有什么解决方法吗?

最佳答案

func createMultiStringRef() -> ABMutableMultiValueRef {
     let propertyType: NSNumber = kABMultiStringPropertyType
     return Unmanaged.fromOpaque(ABMultiValueCreateMutable(propertyType.unsignedIntValue).toOpaque()).takeUnretainedValue() as NSObject as ABMultiValueRef
}

关于ios - swift : Issue with saving contact with AddressBook - (Xcode6-Beta5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25204115/

相关文章:

iphone - 在 XCode 中发送 HTTPS 请求 (iOS)

ios - Firebase - for 循环 Swift 中嵌套的 observeSingleEvent 方法

ios - 如何调整 UIImage 的大小以减小上传图片的大小

swift - 找不到接受提供的参数的 'init' 的重载

ios - 在 iOS 应用程序中使用 AWS Cognito 和 Facebook 登录时 IdentityId 为 Nil

ios - Result.Framework 未在 TrueTime 中找到?

ios - UICollectionView 2种不同的背景颜色

ios - Swift:无法在自定义 View 上调用 removeFromSuperview()

ios - AVQueuePlayer 不前进到 iOS 8 中的下一个项目

ios - 获取 UITableViewCell 细节附件 View 的图像