I'm using XPC in one of my apps on 10.8. It's got the standard setup with protocols defined for exported interface and the remote interface. The problem I run into is with one of my methods on the exported interface.
I have a model class, lets just call it Foo
. This class conforms to NSSecureCoding
, implements +supportsSecureCoding
, and encodes/decodes the internal properties correctly using the secure coding methods. When passing this object through a method on my exported interface that only involves a single instance, it works fine.
The problem occurs when I want to pass a collection of these objects, or a NSArray
of Foo
objects. Here's an example of what the signature on the exported interface looks like:
- (void)grabSomethingWithCompletion:(void (^)(NSArray *foos))completion;
And I've whitelisted the Foo
class, as noted in the documentation:
NSSet *classes = [NSSet setWithObject:Foo.class];
[exportedInterface setClasses:classes forSelector:@selector(grabSomethingWithCompletion:) argumentIndex:0 ofReply:YES];
Now this should make it so that this array can be safely copied across the process and decoded on the other side. Unfortunately this doesn't seem to be working as expected.
When calling the method on the exported protocol, I receive an exception:
Warning: Exception caught during decoding of received reply to message 'grabSomethingWithCompletion:', dropping incoming message and calling failure block.
Exception: Exception while decoding argument 1 of invocation: return value: {v} void target: {@?} 0x0 (block) argument 1: {@} 0x0
Exception: value for key 'NS.objects' was of unexpected class 'Foo'. Allowed classes are '{( NSNumber, NSArray, NSDictionary, NSString, NSDate, NSData )}'.
This almost seems like it didn't even register the whitelisting I performed earlier. Any thoughts?