Skip to content

Commit

Permalink
Merge pull request tristanhimmelman#391 from PhilCai1993/rename
Browse files Browse the repository at this point in the history
update function name to make it clear
  • Loading branch information
tristanhimmelman committed Feb 19, 2016
2 parents 76225f9 + 3641299 commit 1bc63bc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ObjectMapper/Core/Map.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private func valueFor(keyPathComponents: ArraySlice<String>, dictionary: [String
return valueFor(tail, dictionary: dict)
} else if let array = object as? [AnyObject] where keyPathComponents.count > 1 {
let tail = keyPathComponents.dropFirst()
return valueFor(tail, dictionary: array)
return valueFor(tail, array: array)
} else {
return object
}
Expand All @@ -131,7 +131,7 @@ private func valueFor(keyPathComponents: ArraySlice<String>, dictionary: [String
}

/// Fetch value from JSON Array, loop through keyPathComponents them until we reach the desired object
private func valueFor(keyPathComponents: ArraySlice<String>, dictionary: [AnyObject]) -> AnyObject? {
private func valueFor(keyPathComponents: ArraySlice<String>, array: [AnyObject]) -> AnyObject? {
// Implement it as a tail recursive function.

if keyPathComponents.isEmpty {
Expand All @@ -140,15 +140,15 @@ private func valueFor(keyPathComponents: ArraySlice<String>, dictionary: [AnyObj

//Try to convert keypath to Int as index
if let keyPath = keyPathComponents.first,
let index = Int(keyPath) where index >= 0 && index < dictionary.count {
let index = Int(keyPath) where index >= 0 && index < array.count {

let object = dictionary[index]
let object = array[index]

if object is NSNull {
return nil
} else if let array = object as? [AnyObject] where keyPathComponents.count > 1 {
let tail = keyPathComponents.dropFirst()
return valueFor(tail, dictionary: array)
return valueFor(tail, array: array)
} else if let dict = object as? [String : AnyObject] where keyPathComponents.count > 1 {
let tail = keyPathComponents.dropFirst()
return valueFor(tail, dictionary: dict)
Expand Down

0 comments on commit 1bc63bc

Please sign in to comment.