Swift Equatable object
Take exmaple of Post model: ```swift import Foundation struct Post: Identifiable { var id: String } ``` If we don't implement `Equ...
Pagination using GraphQL and SwiftUI
簡單來說就是 `List` render 到最後一個 post 的時候(藉由 `onAppear` 來偵測 )就繼續 load 剩下的 posts,這樣就能做到 infinite scroll In view: ```swift import SwiftUI str...
Swift Apollo plugin will cache result by default
I try to call the following code again but it doesn't hit my server because the defailt `cachePolicy` is `.returnCacheDataElseFetch` poli...
Use Xcode configuration to store env variables
Follow [thoughtbot's article](https://thoughtbot.com/blog/let-s-setup-your-ios-environments) but don't name the class `Environment` bec...
Use enum to replace String based key in Swift
Take an exmaple from the `Environment.swift` file which is a simple file access the env variable and return it. Before: ```swift import...
Perform mutation with SwiftUI and Apollo client with HTTP token authentication
首先是 Editor View 的部分, Use `@Binding` 關鍵字 ``` // // PostEditor.swift // ios-swift // // Created by Wayne on 2020/3/22. // Copyright © ...
How to use SwiftUI with ViewController
[上一篇文章](/posts/412-how-to-make-multiline-textfield-in-swiftui)為了要實現 multiline text field 結果發現 SwiftUI 並沒有所謂 MultilineTextField 這種東西,想要實現就...
How to make multiline TextField in SwiftUI
SwiftUI 根本就是半殘狀態嘛,靠北連個 multiline TextField 都做不到,還得自己用 `UITextView` 客製化,見 https://stackoverflow.com/questions/56471973/how-do-i-create-a-m...
SwiftUI TextField doesn't support String? type binding, how to fix
## Problem Currently SwiftUI doesn't support `String?` type binding for TextField, it only support `String`, so the following code will ...
Use Apollo (GraphQL) with SwiftUI
This [apollo-ios plugin](https://github.com/apollographql/apollo-ios) let you able to use apollo client to fetch GraphQL API easily, howe...
How to communicate with iframes inside WebView
This is an archive of my post from 2017 (revised by [@morhekil](https://twitter.com/morhekil)), original posted in [medium](https://mediu...
Swift weak keyword
weak keyword 是為了避免 ownership cycle,所謂 ownership cycle 就是當 Object A reference Object B 而 Object B 又 reference Object A 時,兩個 Objects 就會都無法...
iOS 在 screens 之間傳資料
所謂 screens 之間就是 ViewControllers 之間,這裡討論的是 A screen 叫出了 B screen,但 B screen 想要送資料回 A screen 時該怎麼做。 通常如果是 A controller contains B contro...
Swift 回收 memory 的機制 - ARC
Automatic Reference Counting 字面意思就是看 object 被 reference 多少次,沒被 reference 就回收 https://tommy60703.gitbooks.io/swift-language-tradit...
NSRange vs. Range and NSString vs. String
NSRange 是 Objective-C 的 Range, Range 則是 Swift 的 Range,是不同的結構。 但是 iOS API 內因為歷史因素都是給 NSRange ,所以通常要 cast 一下,例如: ```swift func textFiel...