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
// | |
// CatWidget.swift | |
// WidgetCollection | |
// | |
// Created by 李昇輯 on 2024/7/25. | |
// | |
import AppIntents | |
import SwiftUI | |
import WidgetKit |
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
protocol P { | |
func test() | |
} | |
private struct Object { | |
let index: Int | |
} | |
extension Object: P { | |
fileprivate func test() { |
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
class OAO { | |
let concurrent = DispatchQueue(label: "OAO", attributes: .concurrent) | |
let arrayQueue = DispatchQueue(label: "OAO.array", attributes: .concurrent) | |
// Thread-Safe | |
private var _array: [Int] = [] | |
private var array: [Int] { | |
get { |
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
// Model | |
typealias ChannelID = Int | |
struct ChannelGroup { | |
var name: String | |
var channels: [ChannelID] | |
} | |
// View's Model |
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
// designated init | |
init() {} | |
// designated init label | |
init(label: Type) {} | |
// convenience init | |
convenience init() {} | |
// convenience init label |
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
@objc class SettingsViewController: UITableViewController { | |
@objc convenience init() { | |
self.init(categories: SettingCategory.allCases) | |
} | |
init(categories: [SettingCategory]) { | |
super.init(nibName: nil, bundle: nil) | |
} | |
required init?(coder: NSCoder) { |
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
class SettingsViewController: UITableViewController {} | |
func showSettings() { | |
let vc = SettingsViewController() | |
let nav = UINavigationController(rootViewController: vc) | |
self.present(nav, animated: 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
class Channel { | |
final int id; | |
bool isStarred; | |
bool isJoined; | |
bool isEncrypted; | |
Channel.fromJson(Map<String, dynamic> json) | |
: id = json['channel_id'], | |
isStarred = json['is_star'], |
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
import Foundation | |
// valid JSON format | |
// 1. null | |
// 2. String | |
// 3. Number | |
// 4. { "key": JSON, "key": JSON, ... } | |
// 5. [JSON, JSON, ...] | |
enum Status { |
NewerOlder