小编Gov*_*ind的帖子

使用swift访问iOS中的联系人详细信息

使用Objective-C时,我们通常使用以下代码来获取详细信息

NSString *firstName = (__bridge_transfer NSString *)ABRecordCopyValue(contactPerson, kABPersonFirstNameProperty);
Run Code Online (Sandbox Code Playgroud)

在Swift中我尝试了以下内容

var firstName : NSString = ABRecordCopyValue(contactPerson, kABPersonFirstNameProperty).takeUnretainedValue() as NSString
Run Code Online (Sandbox Code Playgroud)

而且由于错误,我无法构建

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

nsstring abaddressbook ios swift

4
推荐指数
2
解决办法
1389
查看次数

标签 统计

abaddressbook ×1

ios ×1

nsstring ×1

swift ×1