Commit bd3a55c6 authored by Eyad Hasan's avatar Eyad Hasan
Browse files

More broken than normal, Basically deleted some old stuff but didn't bother to...

More broken than normal, Basically deleted some old stuff but didn't bother to put anything in place, hopefully I'll do that today, but I'm still half asleep so maybe not
parent d5c90942
......@@ -16,7 +16,7 @@ class SRCTNetworkController: NSObject {
//https://whatsopen.gmu.edu/api/facilities/?format=json
public static func performDownload(completion: @escaping (_ result: Array<Facility>) -> Void) {
let requestURL: NSURL = NSURL(string: "https://whatsopen.dhaynes.xyz/api/facilities/?format=json")!
let requestURL: NSURL = NSURL(string: "https://whatsopen.dhaynes.xyz/api/facilities/?format=json")!
let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL)
let session = URLSession.shared
let task = session.dataTask(with: urlRequest as URLRequest) {
......@@ -24,23 +24,15 @@ class SRCTNetworkController: NSObject {
let httpResponse = response as! HTTPURLResponse
let statusCode = httpResponse.statusCode
if (statusCode == 200) {
if let dataN = data {
if let dataN = data {
let json = try! JSONSerialization.jsonObject(with: dataN, options: []) as! Array<Any>
var facilities = Array<Facility>()
for f in json {
let fJson = f as! [String: Any]
if let facility = Facility(json: fJson) {
facilities.append(facility)
}
}
}
print(facilities)
completion(facilities)
......@@ -49,7 +41,7 @@ class SRCTNetworkController: NSObject {
}
}
print(Facility.MainSchedule.self)
task.resume()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment