Skip to content
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

mapArray(XMLObject: Any?) -> [N]? bug #5

Closed
An1metall opened this issue Mar 7, 2018 · 1 comment
Closed

mapArray(XMLObject: Any?) -> [N]? bug #5

An1metall opened this issue Mar 7, 2018 · 1 comment
Assignees
Labels

Comments

@An1metall
Copy link

An1metall commented Mar 7, 2018

If we have XML something like
<Array>
<XMLMappable/>
</Array>
and try to map it like
var array = [XMLMappable]()
array <- map[Array.XMLMappable]
we have empty array instead of array with 1 item.

If think problem method is mapArray(XMLObject: Any?) -> [N]? in Core/XMLMapper.swift
Suggest add else if statement like this.

Before:
public func mapArray(XMLObject: Any?) -> [N]? {
if let XMLArray = XMLObject as? [[String: Any]] {
return mapArray(XMLArray: XMLArray)
}
return nil
}

After:
public func mapArray(XMLObject: Any?) -> [N]? {
if let XMLArray = XMLObject as? [[String: Any]] {
return mapArray(XMLArray: XMLArray)
} else if let object = XMLObject as? [String: Any] {
return mapArray(XMLArray: [object])
}
return nil
}

@gcharita gcharita added the bug label Mar 8, 2018
@gcharita gcharita self-assigned this Mar 8, 2018
@gcharita
Copy link
Owner

gcharita commented Mar 8, 2018

Yes, this is an issue (already referenced in #3 although closed)
This will be fixed in the next release, as soon as I find a little bit of time to test it.
Thank you for your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants