Created
October 20, 2016 13:44
-
-
Save aravindhkumar23/6569e38411d6ce6d3d0c31a3dc1f9f7f to your computer and use it in GitHub Desktop.
sort dictionary inside array, and find match between 2 array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let loggedIn_array = ((loggedInUserSolution.valueForKey("solutions") as? NSArray ?? NSArray()).sort{ | |
(($0 as? Dictionary<String, String> ?? Dictionary<String, String>())["solution_id"]) < (($1 as? Dictionary<String, String> ?? Dictionary<String, String>())["solution_id"]) | |
}) as NSArray | |
let opposite_array = ((oppositeUserSolution.valueForKey("solutions") as? NSArray ?? NSArray()).sort{ | |
(($0 as? Dictionary<String, String> ?? Dictionary<String, String>())["solution_id"]) < (($1 as? Dictionary<String, String> ?? Dictionary<String, String>())["solution_id"]) | |
}) as NSArray | |
print("loggedIn_array ::\(loggedIn_array)") | |
print("opposite_array ::\(opposite_array)") | |
if (loggedIn_array.count == opposite_array.count) { | |
print("same count") | |
if(loggedIn_array == opposite_array){ | |
print("same and match") | |
// redirect to Congragulation page | |
let vc:CongratulationViewController = CongratulationViewController() | |
self.navigationController?.showViewController(vc, sender: self) | |
} else { | |
print("same but doesnot match") | |
// redirect to DisputeSolutionViewController | |
let vc:DisputeSolutionViewController = DisputeSolutionViewController() | |
vc.disputeConversationId = conversationID | |
self.navigationController?.showViewController(vc, sender: self) | |
} | |
}else{ | |
print("not a same count") | |
// array count not same | |
let vc:DisputeSolutionViewController = DisputeSolutionViewController() | |
vc.disputeConversationId = conversationID | |
self.navigationController?.showViewController(vc, sender: self) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment