Created
March 28, 2020 02:31
-
-
Save paulw11/b9c4a847cd641fb56d9bff07da66be52 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 passedEarnings = [ | |
[ | |
"actual":"<null>", | |
"code" : "AUTO.US", | |
"date" : "2019-12-31", | |
"difference" : "<null>", | |
"estimate" : "-0.12", | |
"percent" : "<null>", | |
"report_date" : "2020-03-27"], | |
[ | |
"actual" : "<null>", | |
"code" : "APTX.US", | |
"date" : "2019-12-31", | |
"difference" : "<null>", | |
"estimate" : "-0.5600000000000001", | |
"percent" : "<null>", | |
"report_date" : "2020-03-30" | |
], | |
[ | |
"actual" : "<null>", | |
"code" : "APTX.AUS", | |
"date" : "2019-12-31", | |
"difference" : "<null>", | |
"estimate" : "-0.5600000000000001", | |
"percent" : "<null>", | |
"report_date" : "2020-03-30" | |
] | |
] | |
func createArray(from earnings:[[String:String]] ) -> [String:[[String:String]]] { | |
var arrayOfEarningsDicts = [String:[[String:String]]]() | |
for earning in earnings { | |
guard let reportDate = earning["report_date"] else { | |
break | |
} | |
arrayOfEarningsDicts[reportDate, default:[[String:String]]()].append(earning) | |
} | |
return arrayOfEarningsDicts | |
} | |
let array = createArray(from: passedEarnings) | |
for e in array.values { | |
for a in e { | |
print(a["report_date"]!) | |
This file contains hidden or 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
2020-03-27 | |
2020-03-30 | |
2020-03-30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment