|
View your shopping cart.
Recent topics
Recent Comments |
Structure OutputI've been working on a little patch for a few days now, and I'm almost done. I've got all my internal figuring done. All I need to do is output a Structure. I have 2 issues:
I've seen native QC patches output structures that seem to be arrays, rather than dictionaries, as they don't have the key:value or key:object format. Instead, they have [indexnumber]:object, or somesuch. My substructures, I know exactly how many items they'll have, and a dictionary, and its key:object format makes sense for them. The substructures contain my image object, which is a subclass of NSObject that conforms to <QCOutputImage>. My questions:
I can handle the data gathering.
More like this
|
if you're coding a plug-in, you can declare your output to be of type NSArray instead of NSDictionary. Not properly documented that, but certainly helps. You could check the source of my SPK-StringToImageStructure plugin to get an idea of using dictionaries and arrays in the output.
if you're making a macro patch... good luck to you =]
toby
you can iterate of a dictionary's keys or values array ([myDict keys] or [myDict values] I believe) to see what's inside. Alternatively, you can just query the dict for the object with a given key, and it'll return nil if it's not found (i.e. [myDict objectForKey:@"foo"] will return nil if no key foo exists).
creating an array-like structure is done with the initWithArray method (not quite sure how it's exported in the official API, but toby addressed this anyway I think)
variable numbers of substructures isn't a problem at all (gltools, kineme3d, and opencv all handle variable-length structures without any magic or handwaving) -- simply add all the dictionaries/arrays you want to export into a parent dictionary/array, and use the parent array/dictionary to create the QCStructure object.