Recently on the list, there was a question regarding creating your own protocols for QC. This is perhaps a 3+ part problem, and I've only addressed 1. Never the less, it's a good start I think :)
The Parts:
- The Edit Conformance Information menu (I've addressed this one)
- The Composition Repository patch (not addressed)
- The New From Template Dialog (not addressed)
Making a new protocol is actually really simple. Using our "Skanky SDK" template makes it a snap.
Create a new project. Remove the CustomPatch.h, CustomPatch.m, CustomPatchUI.h, and CustomPatch.m files in the Patches directory (we don't need them for this exercise). The function we'll be working on is registerNodesWithManager:, located in CustomPatchPrincipal.m. Remove references and #imports of these files too.
Add these following lines before the @implementation line:
@interface QCCompositionRepository: NSObject
@end
This tells the compiler a bit about the Compo Repo that we're working with (actually, it doesn't say much at all, just that it's an extant class).
Next, clear out the registerNodesWithManager function. We're not adding patches, so we don't need any of the auto-generated stuff in there.
Next, the protocol dictionary construction!:
// add and remove your specific keys to the
// appropriate structs -- Use the port's class
// as the object, and a name that follows the pattern
[optionalInputDict setObject:[QCStructurePort class]
forKey:@"_protocolInput_OptionalInputStruct"];
[requiredInputDict setObject:[QCStructurePort class]
forKey:@"_protocolInput_RequiredInputStruct"];
[optionalOutputDict setObject:[QCStructurePort class]
forKey:@"_protocolInput_OptionalOutputStruct"];
[requiredOutputDict setObject:[QCStructurePort class]
forKey:@"_protocolInput_RequiredOutputStruct"];
// here we set some metadata about the protocol:
// the display name (in the conformance dialog),
// and whether or not we allow consumer patches.
// (True in this example)
[infoDict
setObject:@"My Protocol's Display Name"
forKey:@"name"];
[infoDict
setObject
:[NSNumber numberWithBool
:TRUE
] forKey:@"allowConsumers"];
// We add the required and optional inputs
// to the protocol dictionary...
[infoDict setObject:optionalInputDict
forKey:@"optionalInputKeys"];
[infoDict setObject:requiredInputDict
forKey:@"requiredInputKeys"];
[infoDict setObject:optionalOutputDict
forKey:@"optionalOutputKeys"];
[infoDict setObject:requiredOutputDict
forKey:@"requiredOutputKeys"];
// the we register it!
[[QCCompositionRepository sharedCompositionRepository]
registerProtocol:@"com.MyCompanyName.My-Protocol-Name"
withDescription:infoDict];
// here you should release all the dictionaries.
// I'm lazy though, so you'll have to write that
// yourself.
Feel free to use this code however you want. If you do though, please drop me a line or comment on this post, so I know I didn't waste all this time for nothing :)