The reference documentation for the class NSUniqueIdentifier claims that unique ID specifiers are evaluated in the following scheme:

  1. If the container implements a method whose selector matches the relevant valueIn<Key>WithUniqueID: pattern established by scripting key-value coding, the method is invoked. This method can potentially be very fast, and it may be relatively easy to implement.

  2. As is the case when evaluating any script object specifier, the container of the specified object is given a chance to evaluate the object specifier. If the container class implements the indicesOfObjectsByEvaluatingObjectSpecifier: method, the method is invoked. This method can potentially be very fast, but it is relatively difficult to implement.

  3. An NSWhoseSpecifier object that specifies the first object whose relevant 'ID ' attribute matches the ID is synthesized and evaluated. The NSWhoseSpecifier object must search through all of the keyed elements in the container, looking for a match. The search is potentially very slow.

However, I am not seeing valueIn<Key>WithUniqueID: getting called. To give you an example, I have a class where I describe the object specifier in the following way:

- (NSScriptObjectSpecifier *)objectSpecifier
{
    assert(self.documentID);
    assert(self.controller);
    NSScriptObjectSpecifier *containerRef = self.controller.objectSpecifier;
    assert(containerRef);
    assert(containerRef.keyClassDescription);

    return [[NSUniqueIDSpecifier alloc] initWithContainerClassDescription:containerRef.keyClassDescription
                                                   containerSpecifier:containerRef
                                                                  key:@"allObjects"
                                                             uniqueID:self.documentID];
}

The method I have defined in the container class is - (id)valueInAllObjectsWithUniqueID:(NSString *)uniqueID is the method I have defined:

- (id)valueInAllObjectsWithUniqueID:(NSString *)uniqueID {
    return [self objectWithIdentifier:uniqueID];
}

In the class corresponding to the container I've also overridden -respondsToSelector: to debug this further, and observe that the only relevant method the scripting system queries is indicesOfObjectsByEvaluatingObjectSpecifier: right after -objectSpecifier above is called (and confirmed to return a non-nil result with the container class description and container specifier consistent with the container's class receiving method calls right after the object specifier is evaluated).

Any ideas? This is on OSX Mavericks (10.9.4).

0

There are 0 answers