Join a conversation, pose a question, or help a fellow user: The best place to discuss all things Karelia.
You are not logged in.
Pages: 1
Mike:
I've run into another unexpected "gotcha" with my plugin. The method:
// For when you need to guarantee the element's ID is unique within the document.
- (NSString *)startElement:(NSString *)elementName
preferredIdName:(NSString *)preferredID
className:(NSString *)className
attributes:(NSDictionary *)attributes;I was expecting this to generate a unique ID for every plugin instance in the "document", but it only creates unique IDs for multiple instances within a single collection. ie, if I insert 3 plugins in 3 different collections, it assigns the same ID to all 3.
Is this normal behavior, or should they all be unique? Is there a way to make every instance unique?
Sean
Offline
Hi Sean,
IDs from that method are unique within the page being generated. If you want a site-wide unique ID, that would have to be generated and stored yourself, such as from the CFUUID API.
Offline
IDs from that method are unique within the page being generated. If you want a site-wide unique ID, that would have to be generated and stored yourself, such as from the CFUUID API.
OK, thanks Mike. Looks like I have more work to do.
Alternatively, is there such thing as a "shared" inspector, or properties? To keep them all in-sync?
Sean
Offline
I'm not really sure what you mean!
Sandvox is free to instantiate as many copies of your SVInspector as it likes, since the user can have multiple Inspectors open at once.
We don't provide any shared properties as such. But of course your plug-in can store whatever it likes as its own state. You could store things in NSUserDefaults so long as the keys are properly prefixed I guess.
Offline
Mike, don't know how best to explain the situation, but I'm left with 3 choices:
provide a means to insure site-wide unique IDs, or ...
provide a means to auto-synchronize ALL plugin instances to a single set of properties, or ...
leave it up to the user to ensure synchronized properties
CFUUID would work for unique IDs, but produces very long, non-descript, numerical strings. Still investigating it.
Auto-synchronizing means that changes made to any single inspector would have to automatically propagate to ALL other instances of the plugin.
For the moment, I'm using #3 - leave it up to the user. For that, I am using NSUserDefaults, by manual "Save" button, not automatically. This is still error-prone though. Documented in the demo plugin:
http://www.macalchemy.com/nmdemo/demo-p … nudemo.zip
Sean
Offline
Pages: 1