Access your contact information in iOS using Quick

When using Objective-C, we usually use the following code to get information

NSString *firstName = (__bridge_transfer NSString *)ABRecordCopyValue(contactPerson, kABPersonFirstNameProperty);

In Swift, I tried the following

var firstName : NSString = ABRecordCopyValue(contactPerson, kABPersonFirstNameProperty).takeUnretainedValue() as NSString

and I can’t build because of an error

Bitcast requires both operands to be pointer or neither
  % 224 = bitcast% objc_object *% 223 to% PSs9AnyObject_,! Dbg! 486
Bitcast requires both operands to be pointer or neither
  % 225 = bitcast% PSs9AnyObject_% 224 to i8 *,! Dbg! 486
LLVM ERROR: Broken function found, compilation aborted!
Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 1
+4
source share
2 answers

Xcode6 beta 4 .

var firstName: NSString! = Unmanaged<CFString>.fromOpaque(ABRecordCopyValue(record, kABPersonFirstNameProperty).toOpaque()).takeUnretainedValue().__conversion()
+3

Xcode 6 GM

let firstName = ABRecordCopyValue(contactRecord, kABPersonFirstNameProperty).takeRetainedValue() as String

, .

+12

All Articles