Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Use of NSDictionary and NSArray in Mappable protocol #80

Open
wdominik opened this issue Sep 21, 2016 · 7 comments
Open

Use of NSDictionary and NSArray in Mappable protocol #80

wdominik opened this issue Sep 21, 2016 · 7 comments

Comments

@wdominik
Copy link

The Mappable protocol uses NSDictionary and NSArray in its convenience methods.

public static func from(_ JSON: NSDictionary) -> Self?
public static func from(_ JSON: NSArray) -> [Self]?

Since Swift continues to move away from Objective C with 3.0, I would propose to change the types to [String: Any] and [Any]/[[String: Any]] so it integrates more naturally in Swift development. Or is there any good reason to prefer NSDictionary/NSArray over these?

@sberrevoets
Copy link

sberrevoets commented Sep 22, 2016

Thanks for bringing this up! We have had the same conversation and the (tentative) plan is to move away from NSDictionary/NSArray in favor of the Swift equivalents. I can't provide a timeline unfortunately, but it will likely be part of the final Swift 3 release.

@wdominik
Copy link
Author

Thanks for your reply! I also think it is a good idea to schedule it with the Swift 3 release, since Swift 3 introduces a lot of breaking changes anyway.

@keith
Copy link
Contributor

keith commented Sep 24, 2016

@mergesort can you remind me what issue you were seeing because of this?

@mergesort
Copy link

It wasn't an issue so much as annoyance that have to cast try T.from(JSON as NSDictionary) when parsing a response. I'd mentioned that I was going to try it out to make sure it was just as simple as that, and it indeed is, everything parses find when adding as NSDictionary.

That said, I'm never going to say no to a pure Swift solution. 😄

@keith
Copy link
Contributor

keith commented Oct 9, 2016

The one thing currently stopping us from doing this is that the last time we checked (with Swift 1.0) the cost for bridging was significant. We'll have to do some simple benchmarks to see if this is still the case. If that is no longer a problem we will definitely change them!

@aabanaag
Copy link

aabanaag commented Oct 5, 2018

Any update regarding this?

@keith
Copy link
Contributor

keith commented Oct 24, 2019

Contributions welcome!

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

No branches or pull requests

5 participants