我想查看SD卡被移除或重新插入Cocoa应用程序的时间。我怎样才能做到这一点?我尝试使用以下代码,但它显示错误:
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)
请给我一些建议。提前谢谢。
答案 0 :(得分:1)
您似乎需要在Target的属性中添加DiskArbitration.framework
。