AVPlayer Background Design
-
使用NSNotification来监听进入后台和前台事件
.UIApplicationWillEnterForeground
.UIApplicationDidEnterBackground
-
长按home键不会响应
1.
中的两个通知事件,需要同时使用以下通知.UIApplicationWillResignActive
.UIApplicationDidBecomeActive
protocol CodableDefaultSource { | |
associatedtype Value: Codable | |
static var defaultValue: Value { get } | |
} | |
enum CodableDefault {} | |
extension CodableDefault { | |
@propertyWrapper |
public let localBundle = Bundle.fixedModule | |
private final class CurrentBundleFinder {} | |
private let bundleNameIOS = "Backend_Backend" | |
private let bundleNameTests = "Backend_BackendTests" | |
extension Foundation.Bundle { | |
/// Returns the resource bundle associated with the current Swift module. |
/// Modal 转场动画 | |
class PresentTransition: NSObject, UIViewControllerAnimatedTransitioning { | |
enum Transition { | |
case present | |
case dismiss | |
} | |
private var tran: Transition = .present | |
import UIKit | |
extension UIViewController { | |
static var rootViewController: UIViewController? { | |
guard let keyWindow = UIApplication.shared.delegate?.window ?? UIApplication.shared.windows.first(where: { $0.isKeyWindow && $0.rootViewController != nil }) else { return nil } | |
return keyWindow.rootViewController | |
} | |
static var topMostController: UIViewController? { |
String(cString: __dispatch_queue_get_label(nil), encoding: .utf8) |
private struct OrderTime: Sequence, IteratorProtocol { | |
struct DayHour { | |
let date: Date | |
let hours: [Date] | |
} | |
let minimumDate: Date | |
let maximumDate: Date | |
import RxCocoa | |
import RxSwift | |
import Kingfisher | |
import NSObject_Rx | |
import WebKit | |
/// 缓存管理 | |
final class CacheManager: HasDisposeBag { | |
/// 缓存类型 |
public func resolve<T>(_ jsonDictionary: [String: Any], keyPath: String) -> T? { | |
var current: Any? = jsonDictionary | |
keyPath.split(separator: ".").forEach { component in | |
if let maybeInt = Int(component), let array = current as? Array<Any> { | |
current = array[maybeInt] | |
} else if let dictionary = current as? JSONDictionary { | |
current = dictionary[String(component)] | |
} | |
} |
使用NSNotification来监听进入后台和前台事件
.UIApplicationWillEnterForeground
.UIApplicationDidEnterBackground
长按home键不会响应 1.
中的两个通知事件,需要同时使用以下通知
.UIApplicationWillResignActive
.UIApplicationDidBecomeActive
struct AnyAnimal: Animal { | |
let name: String | |
private let walker: () -> Void | |
private let eater: (Any) -> Void | |
init<T: Animal>(_ animal: T) { | |
name = animal.name | |
walker = { |