我相信一旦有人指点我正确的方向,这就是微不足道的问题,所以我很抱歉问了一个愚蠢的问题。然而,我已经搜索了几天,但我无法弄清楚我做错了什么。
场景:创建一个简单的共享扩展程序,接收图像文件
问题:当我访问附件时,处理程序从未被调用,尽管我可以看到“public.jpg”在itemProvider中,但我找不到数据在哪里?
我已经做了什么:
1) defined NSExtensionActivationSupportsImageWithMaxCount = 1 as my only activation rule
2) added CoreMedia framework to the extension
3) added the same group to both app and app extension
4) made sure both have the group (1) in the entitlement
5) made sure both are using a certificate/app id with that group enabled
6) clean and rebuild several times to no avail.
代码如下:
- (void)didSelectPost {
/
for (NSExtensionItem *item in self.extensionContext.inputItems) {
for (NSItemProvider *itemProvider in item.attachments) {
if ([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypeImage]) {
I can hit this breakpoint --> [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeImage options:nil completionHandler:^(UIImage *image, NSError *error) {
but not this one --> photo = image;
}];
break;
}
}
}
.... and so on and so forth