Mac OS X 10.10.5: Scripting Bridge can't correctly deduce Cocoa class for "root task" from OmniFocus
| Originator: | amorya | ||
| Number: | rdar://24042539 | Date Originated: | 04-Jan-2016 06:08 PM |
| Status: | Open | Resolved: | |
| Product: | OS X | Product Version: | Mac OS X 10.10.5 (14F1021) |
| Classification: | Other Bug | Reproducible: | Sometimes |
I try to obtain an OmniFocus task object by doing this:
OFTask *ofTask = [self.omniFocus.defaultDocument.flattenedTasks objectWithID:taskID];
If "taskID" contains the ID of a task that is the root task of a project, I run into trouble. I end up with an object of class SBObject, which looks like this if I print it in the debugger:
<SBObject @0x618000a5fb00: rootTask of OmniFocusProject id "nLBEWwnG6_a" of OmniFocusDocument id "g_4SrQjMH8I" of application "OmniFocus" (75814)>
If I call [ofTask name], I get "unrecognised selector".
I have discovered a workaround, in the form of this code:
OFTask *ofTask = [self.omniFocus.defaultDocument.flattenedTasks objectWithID:taskID];
if (ofTask) {
id context = ofTask._context;
voidPtr specifier = ofTask._specifier;
OFTask *properTask = [[[self.omniFocus classForScriptingClass:@"task"] alloc] initWithContext:context specifier:specifier];
;
}
If I then log properTask, I get:
<OmniFocusTask @0x600000040570: OmniFocusFlattenedTask id "nLBEWwnG6_a" of defaultDocument of application "OmniFocus" (75814)>
I can then successfully call [properTask name].
If, however, I call [properTask get], I once again end up with an unusable SBObject that doesn't respond to anything.
This may be a similar issue to in rdar://20515878.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!