Skip to content

Commit

Permalink
Reduce dynamic cast
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Oct 18, 2016
1 parent 766c033 commit 64827ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/JAYSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ extension JAYSON {
/// if key is not found, return JAYSON.null
public subscript (key: String) -> JAYSON {
get {
return (source as? [String : Any])
return (source as? NSDictionary)
.flatMap { $0[key] }
.map { JAYSON(source: $0, breadcrumb: Breadcrumb(jayson: self, key: key)) } ?? JAYSON.null
}
Expand All @@ -184,7 +184,7 @@ extension JAYSON {
/// if index is not found return JAYSON.null
public subscript (index: Int) -> JAYSON {
get {
return (source as? [Any])
return (source as? NSArray)
.flatMap { $0[index] }
.map { JAYSON(source: $0, breadcrumb: Breadcrumb(jayson: self, index: index)) } ?? JAYSON.null
}
Expand Down

0 comments on commit 64827ae

Please sign in to comment.