Swift:保存与AddressBook联系的问题 - (Xcode6-Beta5)

BaS*_*Sha 2 abaddressbook ios swift ios8

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

let multiPhone : ABMutableMultiValueRef = ABMultiValueCreateMutable(kABMultiStringPropertyType)
Run Code Online (Sandbox Code Playgroud)

'int' is not convertible to 'ABPropertyType'
Run Code Online (Sandbox Code Playgroud)

可能是,

func ABMultiValueCreateMutable(type: ABPropertyType) -> Unmanaged<ABMutableMultiValueRef>!
Run Code Online (Sandbox Code Playgroud)

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

var kABMultiStringPropertyType: Int { get }
Run Code Online (Sandbox Code Playgroud)

返回Int而不是UInt32.

有什么解决方法吗?

小智 7

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