这是我大约一个小时前才知道的事情,但是如果您的应用程序尝试通过类访问联系人(以前是通讯簿)数据ABAddressBook
,则会提示用户确认,就像在何时提示您确认一样iOS应用程序尝试访问联系人数据。然后安全和隐私首选项窗格将更新,您将看到您的应用程序列在隐私列表下。
因此,如果您尝试在应用程序被阻止的情况下访问联系人数据,您将在 Xcode 中收到错误消息,如“地址簿访问被拒绝执行路径中的可执行文件......”您可以ABAddressBookGetAuthorizationStatus()
在 iOS 中检查隐私状态。 您如何确定您的应用程序在 OS X 中是否具有隐私权限?
此外,如果您有答案,我想知道 Mac OS 将“隐私”选项卡下的应用程序列表存储在哪里?我检查了用户的首选项文件夹。但我没有看到任何文件。
谢谢您的帮助。
//编辑 1 // 以下是应用程序尝试使用 ABAddressBook 访问时显示的错误输出ABAddressBook *addressBook = [ABAddressBook sharedAddressBook];
:
2013-08-14 21:47:59.796 AppName[5374:1803] Address book access is denied for executable at path: /Users/Jim/Library/Developer/Xcode/DerivedData/AppName-eymlymijdmbqaldaqcaecgdyroxa/Build/Products/Debug/AppName.app/Contents/MacOS/AppName
(
0 AddressBook 0x00007fff8a1232fc __ABIsAccessGranted_block_invoke_0 + 36
1 libdispatch.dylib 0x00007fff93f5b0b6 _dispatch_client_callout + 8
2 libdispatch.dylib 0x00007fff93f5b041 dispatch_once_f + 50
3 AddressBook 0x00007fff8a123258 ABIsAccessGranted + 40
4 AddressBook 0x00007fff8a12319e +[ABAddressBook sharedAddressBook] + 12
5 AppName 0x00000001000180e7 -[AppDelegate extractWorkAddresses] + 55
6 AppName 0x0000000100011a68 -[AppDelegate extractWork1Address:] + 72
7 AppKit 0x00007fff8c9f6989 -[NSApplication sendAction:to:from:] + 342
8 AppKit 0x00007fff8cb2c37c -[NSMenuItem _corePerformAction] + 406
9 AppKit 0x00007fff8cb2c06a -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 133
10 AppKit 0x00007fff8c81928f -[NSMenu _internalPerformActionForItemAtIndex:] + 36
11 AppKit 0x00007fff8c819117 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 135
12 AppKit 0x00007fff8cb25175 NSSLMMenuEventHandler + 342
13 HIToolbox 0x00007fff8a84cd1a _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1206
14 HIToolbox 0x00007fff8a84c1e9 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 410
15 HIToolbox 0x00007fff8a861fc9 SendEventToEventTarget + 40
16 HIToolbox 0x00007fff8a898ca9 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 443
17 HIToolbox 0x00007fff8a83da21 SendMenuCommandWithContextAndModifiers + 59
18 HIToolbox 0x00007fff8a83d9d3 SendMenuItemSelectedEvent + 254
19 HIToolbox 0x00007fff8a83d85f _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 94
20 HIToolbox 0x00007fff8a8198bb _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 605
21 HIToolbox 0x00007fff8a818ec8 _HandleMenuSelection2 + 565
22 AppKit 0x00007fff8c9e48f6 _NSHandleCarbonMenuEvent + 245
23 AppKit 0x00007fff8c906acf _DPSNextEvent + 2073
24 AppKit 0x00007fff8c905e22 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
25 AppKit 0x00007fff8c8fd1d3 -[NSApplication run] + 517
26 AppKit 0x00007fff8c8a1c06 NSApplicationMain + 869
27 AppName 0x0000000100002092 main + 34
28 AppName 0x0000000100002064 start + 52
)