PokeMaster app 现在已经是一个具有完整功能的 SwiftUI app 了。麻雀虽小,五脏俱全,在这个示例 app 里,我们涉及到了一个一般性的 iOS app 所需要的大部分内容:
- 如何构建内容展示的列表
- 如何构建用户交互的表单
- 如何进行网络请求并把内容展示出来
- 如何响应用户的手势
- 如何在不同页面之间进行导航
- 以及,如何通过一定的架构将所有上面的内容整合起来
| class CabalInstall < Formula | |
| desc "Command-line interface for Cabal and Hackage" | |
| homepage "https://www.haskell.org/cabal/" | |
| url "https://hackage.haskell.org/package/cabal-install-2.4.1.0/cabal-install-2.4.1.0.tar.gz" | |
| sha256 "69bcb2b54a064982412e1587c3c5c1b4fada3344b41b568aab25730034cb21ad" | |
| head "https://github.com/haskell/cabal.git", :branch => "2.4" | |
| bottle do | |
| cellar :any_skip_relocation | |
| sha256 "4c9ad9914b483ffb64f4449bd6446cb8c0ddfeeff42eddde9137884af3471825" => :mojave |
| import Foundation | |
| import Combine | |
| protocol Resumable { | |
| func resume() | |
| } | |
| extension Subscribers { | |
| class ResumableSink<Input, Failure: Error>: Subscriber, Cancellable, Resumable { | |
| let receiveCompletion: (Subscribers.Completion<Failure>) -> Void |
| final class ViewController: UIPageViewController { | |
| class Inner: UIViewController { | |
| var color: UIColor! | |
| var name: String! | |
| override func viewDidLoad() { | |
| view.backgroundColor = color | |
| } |
| import SwiftUI | |
| class Foo: ObservableObject { | |
| @Published var toggle = false | |
| } | |
| struct ContentView: View { | |
| @EnvironmentObject var foo: Foo | |
| var body: some View { | |
| VStack { |
| https://github.com/sagood/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/KocoClass/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/wujungao/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/asd8855/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/Yuanzc005/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/199305a/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/xuehaiwuya11/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/leoAntu/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/imthunder/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf | |
| https://github.com/Ericfengshi/awesome-iOS-resource/blob/master/Book |
| import UIKit | |
| import WebKit | |
| // Disableing `WKWebView` user zooming by returning `nil` in `UIScrollViewDelegate`'s | |
| // `viewForZooming` delegate method. | |
| // On iOS 12, the delegate method only called when set the web view itself as the | |
| // scroll view delegate. | |
| class WebView: WKWebView {} |
| //Solution goes in Sources | |
| public struct Card: CustomStringConvertible { | |
| enum Suit: String { | |
| case spade = "♤", heart = "♡", club = "♧", diamond = "♢" | |
| // It is not the standard Texas poker rule. All suits are considered equal. | |
| // However, there is a test case to "brake tide by suit", in which "heart" is the largest. | |
| var value: Int { | |
| switch self { |
| // For Request and Response defination, see https://onevcat.com/2016/12/pop-cocoa-2/ | |
| // Define the possible requests | |
| protocol Request { | |
| // Every request should have a corresponding Response | |
| // Here we want all response could contain error cases | |
| associatedtype Response: ErrorResponsable & Decodable | |
| //... | |
| } |