Skip to content

Instantly share code, notes, and snippets.

@Taher-17
Created March 22, 2019 20:40
Show Gist options
  • Save Taher-17/a3d8d7e5f71c54e45ab43e668cf91010 to your computer and use it in GitHub Desktop.
Save Taher-17/a3d8d7e5f71c54e45ab43e668cf91010 to your computer and use it in GitHub Desktop.
Privacy
/*
App.io uses Google Ads - we do not store any user information.
App.io will not save any of the information or apps you choose to monitor
*/
// Makes request to App Figures and fetches App Ranking
func makeRequest(with url: String, type: String){
Alamofire.request(url).responseJSON { response in
if let json = response.data {
do {
let data = try JSON(data: json)
let results = data["results"]
var num = 0 // Free
if self.selectedApp.appPrice != "Free"{
num = 1
}
let entries = results[num]["entries"].array!
var inTopList = false
for entry in entries {
let position = entry["position"].stringValue
let appID = entry["vendor_identifier"].stringValue
if appID == self.selectedApp.appID{
inTopList = true
print("\(position): \(type)")
self.countryRank.append(CountryRank(position: position, country: type))
self.countryRankFiltered = self.countryRank
self.iPhoneRanks.append(position)
}
}
if !inTopList{
print("> 1000: \(type)")
self.countryRank.append(CountryRank(position: "> 1000", country: type))
self.countryRankFiltered = self.countryRank
self.iPhoneRanks.append("> 1000")
}
self.tableView.reloadData()
self.scrollToBottom()
}catch{
print(error.localizedDescription)
}
}
if self.arrayOfCodes.contains("zw"){
self.arrayOfCodes.removeFirst()
self.fetchAllFromAppFigures()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment