我正在开发一个没有 UI 的操作扩展
NSExtensionPointIdentifier : com.apple.services
我正在尝试完成返回 UIView 的扩展程序
MYExternalView *viewTest = [[MYExternalView alloc] init];
NSItemProvider *resultsProvider = [[NSItemProvider alloc] initWithItem:viewTest typeIdentifier:kUTTypeMyCustomType];
NSExtensionItem *resultsItem = [[NSExtensionItem alloc] init];
resultsItem.attachments = @[resultsProvider];
[self.extensionContext completeRequestReturningItems:@[resultsItem] completionHandler:nil];
我的返回视图用非常简单的代码MYExternalView
扩展:NSSecureCoding
MYExternalView.h
@interface MYExternalView : UIView < NSSecureCoding >
@end
MYExternalView.m
@implementation MYExternalView
+ (BOOL)supportsSecureCoding {
return YES;
}
@end
运行此代码我收到错误消息
<Warning>: <NSXPCConnection: 0x17410ae60> connection to service named com.*******.****.****: Warning: Exception caught during decoding of received message, dropping incoming message.
Exception: Exception while decoding argument 0 (#2 of invocation):
<NSInvocation: 0x174262580>
return value: {v} void
target: {@} 0x0
selector: {:} _completeRequestReturningItems:forExtensionContextWithUUID:completion:
argument 2: {@} 0x0
argument 3: {@} 0x0
argument 4: {@?} 0x0 (block)
一些想法来解决我的问题?
如果我返回另一种对象,例如字符串,则一切正常。
谢谢。