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
import Combine | |
import UIKit | |
class ViewController: UIViewController { | |
var viewModel = LoginViewModel() | |
var cancellables = Set<AnyCancellable>() | |
// ... | |
} |
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
// | |
// ViewController.swift | |
// | |
import Combine | |
import UIKit | |
class ViewController: UIViewController { | |
var viewModel = LoginViewModel() | |
var cancellables = Set<AnyCancellable>() |
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
// | |
// ViewController.swift | |
// | |
import UIKit | |
class ViewController: UIViewController { | |
// 1 | |
lazy var stackView: UIStackView = { | |
let view = UIStackView() |
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
// | |
// LoginViewModel.swift | |
// | |
import Combine | |
import Foundation | |
// 1 | |
class LoginViewModel: ObservableObject { | |
// 2 |
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
import Firebase | |
import SwiftUI | |
@main | |
struct RTDBCodableApp: App { | |
init() { | |
FirebaseApp.configure() | |
} | |
var body: some Scene { |
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
struct GameData { | |
static var counter = 0 | |
static var score = 0 | |
static var wins = 0 | |
static var lost = 0 | |
} | |
// usage | |
// write | |
GameData.wins = 5 |
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
class ProfileViewController: UIViewController { | |
//... | |
//... | |
func broadcastInfo() { | |
let image = UIImage() // some image | |
let data: [String: Any] = ["title": "...some text", "subtitle": "longer text", "image": image] | |
// post a notification | |
NotificationCenter.default.post(name: Notification.Name.profileUpdated, object: nil, userInfo: data) | |
} |
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
// 1 | |
extension Notification.Name { | |
static let profileUpdated = Notification.Name("OnProfileUpdated") | |
} | |
class ViewController: UIViewController { | |
//... | |
//... | |
override func viewDidLoad() { | |
super.viewDidLoad() |