forked from tvidenov/appstore-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tihomir Videnov
authored and
Tihomir Videnov
committed
Nov 13, 2016
1 parent
5dc2bd4
commit ee720d3
Showing
88 changed files
with
1,838 additions
and
31 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
...tore.xcodeproj/xcuserdata/tihomirvidenov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
type = "1" | ||
version = "2.0"> | ||
</Bucket> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// ApiService.swift | ||
// AppStore | ||
// | ||
// Created by Tihomir Videnov on 11/12/16. | ||
// Copyright © 2016 Tihomir Videnov. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class ApiService: NSObject { | ||
|
||
static let sharedInstance = ApiService() | ||
|
||
func fetchFeaturedApps(completionHandler: @escaping (FeaturedApps) -> ()) { | ||
|
||
let urlString = "https://dl.dropboxusercontent.com/u/48453924/appStore%3Afeatured.json" | ||
URLSession.shared.dataTask(with: URL(string: urlString)!) { (data, response, error) in | ||
|
||
if error != nil { | ||
print(error ?? "") | ||
return | ||
} | ||
|
||
do { | ||
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String:Any] | ||
print(json) | ||
let featuredApps = FeaturedApps() | ||
featuredApps.setValuesForKeys(json) | ||
|
||
DispatchQueue.main.async { | ||
completionHandler(featuredApps) | ||
} | ||
|
||
} catch let err { | ||
print(err) | ||
} | ||
|
||
}.resume() | ||
} | ||
|
||
func fetchAppDetails(id: Int, completionHandler: @escaping (App) -> ()) { | ||
|
||
let urlString = "http://www.statsallday.com/appstore/appdetail?id=\(id)" | ||
URLSession.shared.dataTask(with: URL(string: urlString)!, completionHandler: { (data, response, error) in | ||
|
||
if error != nil { | ||
print(error ?? "") | ||
return | ||
} | ||
|
||
do { | ||
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String:Any] | ||
|
||
let appDetail = App() | ||
appDetail.setValuesForKeys(json) | ||
|
||
|
||
DispatchQueue.main.async { | ||
completionHandler(appDetail) | ||
} | ||
|
||
} catch let err { | ||
print(err) | ||
} | ||
|
||
}).resume() | ||
} | ||
|
||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// App.swift | ||
// AppStore | ||
// | ||
// Created by Tihomir Videnov on 11/12/16. | ||
// Copyright © 2016 Tihomir Videnov. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class App: NSObject { | ||
|
||
var id: NSNumber? | ||
var name: String? | ||
var category: String? | ||
var imageName: String? | ||
var price: NSNumber? | ||
|
||
var screenshots: [String]? | ||
var desc: String? | ||
var appInformation: AnyObject? | ||
|
||
override func setValue(_ value: Any?, forKey key: String) { | ||
if key == "description" { | ||
self.desc = value as? String | ||
} else { | ||
super.setValue(value, forKey: key) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// Models.swift | ||
// AppStore | ||
// | ||
// Created by Tihomir Videnov on 11/6/16. | ||
// Copyright © 2016 Tihomir Videnov. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class AppCategory: NSObject { | ||
var name: String? | ||
var apps: [App]? | ||
var type: String? | ||
|
||
override func setValue(_ value: Any?, forKey key: String) { | ||
if key == "apps" { | ||
|
||
apps = [App]() | ||
for dict in value as! [[String:Any]] { | ||
let app = App() | ||
app.setValuesForKeys(dict) | ||
apps?.append(app) | ||
} | ||
|
||
} else { | ||
super.setValue(value, forKey: key) | ||
} | ||
} | ||
|
||
|
||
//for offline testing | ||
static func sampleAppCategories() -> [AppCategory] { | ||
|
||
let bestNewAppsCategory = AppCategory() | ||
bestNewAppsCategory.name = "Best New Apps" | ||
|
||
var apps = [App]() | ||
|
||
let frozenApp = App() | ||
frozenApp.name = "Disney Build It: Frozen" | ||
frozenApp.imageName = "frozen" | ||
frozenApp.category = "Entertaiment" | ||
frozenApp.price = NSNumber(value: 3.99) | ||
apps.append(frozenApp) | ||
|
||
bestNewAppsCategory.apps = apps | ||
|
||
|
||
let bestNewGamesCategory = AppCategory() | ||
bestNewGamesCategory.name = "Best New Games" | ||
|
||
var bestNewGamesApps = [App]() | ||
|
||
var telepaintApp = App() | ||
telepaintApp.name = "Telepaint" | ||
telepaintApp.category = "Games" | ||
telepaintApp.imageName = "telepaint" | ||
telepaintApp.price = NSNumber(value: 1.99) | ||
|
||
bestNewGamesApps.append(telepaintApp) | ||
|
||
bestNewGamesCategory.apps = bestNewGamesApps | ||
|
||
return [bestNewAppsCategory, bestNewGamesCategory] | ||
} | ||
|
||
} | ||
|
||
|
||
|
Oops, something went wrong.