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
// Apply Delegate to the UIViewController | |
protocol CoinManagerDelegate { | |
func didUpdateData(_ sender: CoinManager, parsedData: BitcoinData) | |
func didFailWithError(_ sender: CoinManager, error: Error) | |
} | |
// Insert these calls into the component making the call (Manager class) | |
func performRequest(with urlString: String) { | |
let url = URL(string: urlString) |
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
DispatchQueue.main.async { | |
// Update UI components here | |
} |
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
Timer.scheduledTimer(withTimeInterval: interval, repeats: false) { (timer) in | |
// Code here | |
} |
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
// App Delegate | |
import Firebase | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool | |
{ | |
FirebaseApp.configure() | |
return true | |
} | |
// Register User Controller |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Register XIB for custom cell | |
tableView.register(UINib(nibName: K.cellNibName, bundle: nil), forCellReuseIdentifier: K.cellIdentifier) | |
} |
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
// App Deleagate | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
FirebaseApp.configure() | |
_ = Firestore.firestore() | |
return true | |
} | |
// Controller | |
// Init Firestore |
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
// App Delegate | |
import IQKeyboardManagerSwift | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
IQKeyboardManager.shared.enable = true | |
IQKeyboardManager.shared.enableAutoToolbar = false | |
return true | |
} |
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
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return itemArray.count | |
} | |
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "ToDoItemCell", for: indexPath) | |
cell.textLabel?.text = itemArray[indexPath.row] | |
return cell | |
} |
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
@IBAction func addButtonPressed(_ sender: UIBarButtonItem) { | |
let alert = UIAlertController(title: "Add New Todoey Item", message: "", preferredStyle: .alert) | |
var textField: UITextField? = nil | |
let action = UIAlertAction(title: "Add Item", style: .default) { (action) in | |
if let safeTextField = textField { | |
print(safeTextField.text ?? "") | |
} | |
} | |
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
// Controller | |
let defaults = UserDefaults.standard | |
// Reading | |
if let items = defaults.array(forKey: "TodoListArray") as? [String] { | |
itemArray = items | |
} | |
else { | |
itemArray = [] |
OlderNewer