gpt4 book ai didi

objective-c - 如何在 Cocoa 中通知 SD 卡被移除或重新插入

转载 作者:行者123 更新时间:2023-12-03 17:11:47 24 4
gpt4 key购买 nike

我想检查 Cocoa 应用程序中何时移除或重新插入 SD 卡。我怎样才能做到这一点?我尝试使用以下代码,但显示错误:

    static void diskAppearedCallback(DADiskRef disk, void* context)
{
CFDictionaryRef description = DADiskCopyDescription(disk);
NSLog(@"Disk appeared: %@", description);
CFRelease(description);
}

int main(int argc, char **argv)
{
DASessionRef session = DASessionCreate(kCFAllocatorDefault);
DARegisterDiskAppearedCallback(session, kDADiskDescriptionMatchVolumeMountable, diskAppearedCallback, 0);
DASessionScheduleWithRunLoop(session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);

CFRunLoopRun();

return 0;
}

这是一个错误:

 Undefined symbols for architecture i386:
"_DADiskCopyDescription", referenced from:
_diskAppearedCallback in TestAppDelegate.o
"_DARegisterDiskAppearedCallback", referenced from:
-[TestAppDelegate applicationDidFinishLaunching:] in TestAppDelegate.o
"_DASessionCreate", referenced from:
-[TestAppDelegate applicationDidFinishLaunching:] in TestAppDelegate.o
"_DASessionScheduleWithRunLoop", referenced from:
-[TestAppDelegate applicationDidFinishLaunching:] in TestAppDelegate.o
"_kDADiskDescriptionMatchVolumeMountable", referenced from:
-[TestAppDelegate applicationDidFinishLaunching:] in TestAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

请给我一些建议。提前致谢。

最佳答案

您似乎需要在目标属性中添加 DiskArbitration.framework

关于objective-c - 如何在 Cocoa 中通知 SD 卡被移除或重新插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22341197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com