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
| override init(style: UITableViewCellStyle, reuseIdentifier: String?) { | |
| super.init(style: style, reuseIdentifier: reuseIdentifier) | |
| //add UIImageView | |
| customImageView = UIImageView() | |
| customImageView.translatesAutoresizingMaskIntoConstraints = false | |
| customImageView.backgroundColor = UIColor.red | |
| self.addSubview(customImageView) | |
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
| @IBAction func action_loadImage(_ sender: UIButton) { | |
| //disable button in case user click twice | |
| sender.isEnabled = false | |
| //start loading image | |
| startLoad() | |
| } | |
| func startLoad() { | |
| let url = URL(string: "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")! | |
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
| //Session with configuration | |
| private lazy var session: URLSession = { | |
| let config = URLSessionConfiguration.default | |
| config.waitsForConnectivity = true | |
| return URLSession(configuration: config, delegate: self, delegateQueue: nil) | |
| }() |
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
| //MARK: - URLSessionDataDelegate | |
| extension ViewController: URLSessionDataDelegate { | |
| func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) { | |
| guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else { | |
| completionHandler(.cancel) | |
| return | |
| } | |
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
| // | |
| // HTTPNetworking.swift | |
| // urlSessionDemo | |
| // | |
| // Created by Nick on 12/2/18. | |
| // Copyright © 2018 NickOwn. All rights reserved. | |
| // | |
| import Foundation | |
| import UIKit |
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
| // func startLoad() { | |
| // let url = URL(string: "https://lemulotdotorg.files.wordpress.com/2016/10/dsc00737.jpg")! | |
| // //init data | |
| // receivedData = Data() | |
| // let task = session.dataTask(with: url) | |
| // task.resume() | |
| // | |
| // } | |
| func startLoad(){ |
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
| func splitCapitalString(_ textString:String) -> [String] { | |
| var newStringArray = [String]() | |
| for char in textString { | |
| if String(char) == String(char).uppercased() { | |
| newStringArray.append(" ") | |
| } | |
| newStringArray.append(String(char)) | |
| } |
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
| // | |
| // AppDelegate.swift | |
| // CryptoCurrencyPayment | |
| // | |
| // Created by Nick on 4/16/20. | |
| // Copyright © 2020 Nick. All rights reserved. | |
| // | |
| import UIKit | |
| import Firebase |
OlderNewer