从AppDelegate我称之为:
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply{
[SavedSearchesHack getAllMatches:^(MatchCollection * _Nonnull matchCollection) {
reply(@{@"response" : matchCollection});
}];
}
然后在调用回复时出现此错误:
***由于未捕获的异常'NSInvalidUnarchiveOperationException'终止应用程序,原因:'此解码器将只解码采用NSSecureCoding的类。类'Test.MatchCollection'不采用它。'
public class func openParentApplication(userInfo: [NSObject : AnyObject],
reply: (([NSObject : AnyObject], NSError?) -> Void)?) -> Bool
只要我返回像“test”这样的对象而不是MatchCollection,我就不会收到任何错误。
答案 0 :(得分:2)
添加.h
文件
// just the protocol
@interface PacketH: NSObject<NSSecureCoding>
添加.m
文件
+ (BOOL)supportsSecureCoding {
return YES;
}