BaSha
BaSha

Reputation: 2406

Swift : Issue with saving contact with AddressBook - (Xcode6-Beta5)

When I'm trying to store phone number of my new contact, in first step below

let multiPhone : ABMutableMultiValueRef = ABMultiValueCreateMutable(kABMultiStringPropertyType)

gives

'int' is not convertible to 'ABPropertyType'

may be as,

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

accepts ABPropertyType which is declared as typealias ABPropertyType = UInt32 but,

var kABMultiStringPropertyType: Int { get }

returns Int not UInt32.

Any workaround for this?

Upvotes: 2

Views: 696

Answers (1)

Henk
Henk

Reputation: 86

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

Upvotes: 7

Related Questions