1

I'm working on an Action Extension with no UI

NSExtensionPointIdentifier : com.apple.services

I'm trying to complete my extension returning an 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];

My returning view MYExternalView extends NSSecureCoding with very simple code:

MYExternalView.h


@interface MYExternalView : UIView < NSSecureCoding >


@end




MYExternalView.m


@implementation MYExternalView

+ (BOOL)supportsSecureCoding {
    return YES;
}

@end

Running this code i had error message

<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)

Some ideas to solve my problem?

If i return another kind of object, a string for instance, everything work well.

Thanks.

Martino Bonfiglioli
  • 1,567
  • 1
  • 15
  • 29
  • 1
    It may support secure coding, but you are not secure coding it. Wouldn't it be better if you did? Passing around a UIView like this is dubious; passing around an NSData is not. – matt Nov 10 '14 at 17:34
  • that's great, i can try with this http://stackoverflow.com/questions/1169061/how-to-serialize-a-uiview – Martino Bonfiglioli Nov 10 '14 at 17:40

0 Answers0