-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion userInfo #167
Comments
I haven't worked with Would you expect it to live on Also, just to clarify, but you're thinking specifically for custom deserialization and not manual indexing, correct? I'm happy to add this as a future enhancement. |
Exactly - Apple usually uses a dictionary for that purpose.
IMHO adding this object to the XMLIndexer would be best.
Yes, that's right. During our custom deserialization we need to access some information that isn't included in the actual xml file, this would be the perfect place for the |
👍 got it - I'll see if I can get this feature coded soon. Thanks for the feedback! |
One clarifying question around you would imagine implementation... for Would you envision this being a let xml = SWXMLHash.config {
config in
config.userInfo = [ "myUserInfoKey" : myOptions ]
}.parse(xmlToParse)
// ... later ...
xml.userInfo // has the instance of userInfo from above? I think that makes sense to me given that |
I guess this would be fine - But I would try to go a step further and allow the user to change / update the userInfo even after the SWXMLHash instance had been configured. This is something really annoying in Swift's For Apple's typical 'perfect-world' examples (like JSON parsing) this is fine, but in complex object-graphs (I guess an XML is a perfect example for that) it certainly makes sense to update the userInfo even during the actual decoding. So in short: Setting the userInfo in SWXMLHash's config is a good start and for most usecase probably enough - but I would recommend to allow changes to the userInfo afterwards (i.e. |
FYI, I just pushed #171 to try to get some One thing I want to note is that it wasn't as straightforward as I expected in being able to change It looks like this could be possible by changing Let me know if it works for you and I can get this merged and released. Thanks! |
Just try it - work's perfectly - using For now it's fine that the userInfo can't be change afterwards (actually we have a (quick'n'dirty) helper method for the same issue with Maybe you could pin the 'updating of the userInfo' to your roadmap. I understand that a breaking change to your API should happens only if it's absolutely necessary (which IMHO isn't the case right now). |
FYI, I just pushed |
Hi,
we're using your framework extensively and it work's perfectly - but we're missing (only) one thing: Some type of userInfo (
var userInfo: [AnyHashable : Any] { get }
). So that the user can add some custom information to the XMLIndexer.This could be very similar (if not identically) to the userInfo in the latest Swift Codable protocol (e.g. see section userInfo).
Is this something for your project's roadmap?
The text was updated successfully, but these errors were encountered: