在我的OS X应用程序中,我想让用户编辑带有安装在他/她的Mac上的相应动作扩展的图像,例如Mail.app或TextEdit中的图像标记扩展(对于带有图像的RTFD文件) - 或Pixelmator的修复工具(如果有).据我所知,Apple在WWDC '14宣布将有一个公共API来完成这项任务.
遗憾的是,我找不到任何关于如何从主机应用程序角度使用扩展的起点,无论是文档还是样本代码.
我发现你必须将NSSharingPicker的未记录的样式属性设置为非零值,如下所示:
- (IBAction)testSharingPicker:(id)sender
{
NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:@[[self.listing.images.firstObject thumbImage]]];
[picker setValue:@(1) forKey:@"style"];
[picker setDelegate:self];
[picker showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
}
Run Code Online (Sandbox Code Playgroud)
一旦设置了样式值,您就知道自己处于正确的轨道上,因为- (NSArray *)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker sharingServicesForItems:(NSArray *)items proposedSharingServices:(NSArray *)proposedServices我的系统上安装了图像编辑扩展,而不是常规的共享扩展.
您还需要实现一个未记录的委托方法:
- (BOOL)sharingServicePicker:(NSSharingServicePicker *)sharingService shouldShowForView:(NSView*) inView
{
return YES;
}
Run Code Online (Sandbox Code Playgroud)
但是,选择器还没有出现.我得到的只是sender按钮周围的一些奇怪的边框.
在我的Cocoa应用程序中,我想阻止Flash加载到WebView中,并让用户决定是否应该为每个页面显示Flash.(这与通过ClickToFlash插件或Safari扩展程序已经提供的行为相同.由于许可问题,捆绑任何这些扩展可能不是一种选择.)
不幸的是,我试图避免使用的大部分Flash都是通过专门设计的嵌入式JavaScript生成的,以防止轻松阻塞,因此我无法过滤原始HTML以包含Flash对象.
此外,我无法为我的WebView禁用JavaScript,因为当我关闭JavaScript时,我要显示的页面看起来完全不同.
在执行JavaScript之后,但是在加载Flash插件之前,是否有可用于修改页面DOM的通知/挂钩?
或者我应该追求不同的方向?
谢谢,Ilja
我正在维护一个用于访问 USB 设备的库,该库将自身注册为 HID 设备,并使 Mac 应用程序能够执行各种漂亮的操作(GPIO、I2C 等)。该库可以在这里找到:
https://github.com/codemercs-com/io-warrior-mac
由于我将项目升级到 MacOS 10.13 SDK,IOServiceGetMatchingServices() 在从回调调用时返回 nil 迭代器对象DeviceAdded,但不返回错误代码。
我的假设是,自从我在 2002 年左右最初编写这个库以来,IOKit 中的某些内容已经发生了根本性的变化。
我正在注册我的“设备插入”回调,如下所示:
result = IOServiceAddMatchingNotification(gNotifyPort,
kIOFirstMatchNotification, matchingDict,
IOWarriorAdded, NULL, &gIOWarriorAddedIter);
Run Code Online (Sandbox Code Playgroud)
当插入受支持的设备时,确实会调用此回调,但是当我随后调用 IOServiceGetMatchingServices 时,迭代器为零,或者,当其他设备已连接时,仅包含这些设备,而不包含新插入的设备。
io_iterator_t IOWarriorFindHIDDevices ()
{
CFMutableDictionaryRef hidMatchDictionary = IOWarriorSetUpHIDMatchingDictionary ();
// Set up matching dictionary to search the I/O Registry for HID devices we are interested in. Dictionary reference is NULL if error.
if (NULL == hidMatchDictionary) {
PrintErrMsg ("Couldn't create a matching dictionary.");
return 0; …Run Code Online (Sandbox Code Playgroud) 我最近开始研究将levelDB集成到我的项目中的podSpec文件.(https://github.com/iljaiwas/Podspecs/blob/master/LevelDBPodSpec/0.0.1/leveldb.podspec)
但是,当我从主目标中的.mm文件引用任何C++符号时,我得到一个链接器错误,如下所示:
Undefined symbols for architecture x86_64:
"leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, leveldb::DB**)", referenced from:
-[IHLevelDBContext initWithPath:] in IHLevelDBContext.o
Run Code Online (Sandbox Code Playgroud)
这就是编译器调用的样子
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/ilja/Library/Developer/Xcode/DerivedData/LevelDBTest2-aiflqgbevhxzfxbrsdamteybrbao/Build/Products/Debug -F/Users/ilja/Library/Developer/Xcode/DerivedData/LevelDBTest2-aiflqgbevhxzfxbrsdamteybrbao/Build/Products/Debug -filelist /Users/ilja/Library/Developer/Xcode/DerivedData/LevelDBTest2-aiflqgbevhxzfxbrsdamteybrbao/Build/Intermediates/LevelDBTest2.build/Debug/LevelDBTest2.build/Objects-normal/x86_64/LevelDBTest2.LinkFileList -mmacosx-version-min=10.7 -ObjC -fobjc-arc -fobjc-link-runtime -stdlib=libc++ -framework Cocoa -lPods -o /Users/ilja/Library/Developer/Xcode/DerivedData/LevelDBTest2-aiflqgbevhxzfxbrsdamteybrbao/Build/Products/Debug/LevelDBTest2.app/Contents/MacOS/LevelDBTest2
Run Code Online (Sandbox Code Playgroud)
根据我的理解,缺少:: Open调用包含在libPods.a中
nm libPods.a | grep "Open"
U __ZN7leveldb2DB4OpenERKNS_7OptionsERKSsPPS0_
000000000005e5b1 s L___func__._ZN7leveldb6DBImpl24OpenCompactionOutputFileEPNS0_15CompactionStateE
00000000000099d0 T __ZN7leveldb2DB4OpenERKNS_7OptionsERKSsPPS0_
0000000000060ba0 S __ZN7leveldb2DB4OpenERKNS_7OptionsERKSsPPS0_.eh
Run Code Online (Sandbox Code Playgroud)
我似乎可以通过将主应用程序的"编译器"设置从Apple LLVM 4.2更改为LLVM GCC 4.2来解决链接器错误,但此编译器会阻止Objective-C 2.0功能,如下所示:
expected a property attribute before 'strong'
Run Code Online (Sandbox Code Playgroud)
感谢您对我可能做错的任何指示,Ilja
您是否了解现有的Cocoa代理或转发器类,这使我无法使用respondsToSelector:每次我想在其他对象上调用可选方法时进行检查?
而不是写这个:
if ([delegate respondsToSelector:@selector(treeController:canCreateGroupInParent:)])
{
[delegate treeController:treeController canCreateGroupInParent:inGroup];
}
Run Code Online (Sandbox Code Playgroud)
我想写这个:
[[delgate safeForwarder] treeController:treeController canCreateGroupInParent:inGroup];
Run Code Online (Sandbox Code Playgroud)
safeForwarder应该捕获调用并重定向到它的目标,如果它实现了所请求的方法.
任何人都知道这样做的现有组件.不想重新发明轮子.
谢谢,Ilja
cocoa ×4
objective-c ×3
clang++ ×1
cocoapods ×1
flash ×1
iokit ×1
macos ×1
osx-yosemite ×1
webkit ×1