波報 | Pofat 的 Swift 中文電子報

Share this post

波報 #33 - 蒼天無情

pofat.substack.com

波報 #33 - 蒼天無情

Swift 大小事 2023/2/6 - 2023/2/12

Pofat
Feb 13
Share this post

波報 #33 - 蒼天無情

pofat.substack.com

💬 Pofat 的話

上週土耳其和敘利亞發生了可怕的超級大地震,死傷無數,其土地滿目瘡痍,救援也不容易,真心感到難過。想起了 921 和 1022 時的恐懼,更覺得還是好好地隨時善待自己與所愛的人、享受人生吧。

另外要預告本週三將會推出副刊的第一話「2023 如何量測 app 啟動時間」,這個話題來自幾天前和推友的聊天,才發現自己做了不少相關工作但都沒有好好地留下文字紀錄來分享,就拿它來當做起頭吧!

《看前一期 | 所有文章》


🌎 On Swift Community

在 macOS 與 iPadOS 取得位置的新 API

SwiftUI 終於在 macOS 13 與 iPadOS 16 加入更方便在某個 view 裡取得游標位置的 API:onContinuousHover(coordinateSpace:perform:),在 perform 餵入的 closure 可以取得游標位置,更多詳情和範例可以參考 Natalia 的新文章。

使用 SwiftUI Environment 的注意事項

簡而言之,你可以使用巢狀的 keypath 以及它應該是 private var,因為這些值只有在 render 前才會被計算出來,揭露給外部並沒有意義,關於後者也有 lint rule 可以採用。

ChatGPT 幫你寫 SwiftUI 初稿

大家應該都有「這東西我大概知道怎麼做,但細節還要去 Google 或 Stack Overflow 幾次再組合成能動的雛形」的經驗,ChatGPT 在這方面真的可以省下不少時間,這篇文章說明了叫 ChatGPT 用 SwiftUI 來寫一個打字動畫的過程,它給得不一定正確,但你只需要基於這個基礎再做修改通常就能達到預期效果了。

ChatGPT 的 reverse engineering

把 SceneKit 的樹狀結構用 NSLog 印出來,丟給 ChatGPT 後它能回推原本的 SceneKit 程式,還能把 Storyboard 底下對應的 XML 檔改寫成 UI layout code,這個拿來翻修老程式碼會是很棒的工具。

令人困惑的 extension 語法

extension SomeProtocol: where Self: SomeOtherProtocol {
    func c() {}
}

這段程式碼看起來會有自動讓SomeProtocol 繼承了 SomeOtherProtocol的效果,但其實還是它原本的用法,用來定義讓一個遵循這兩個 Protocol 物件自動擁有的預設方法(這裡是 c())。

如何應對 iPhone 14 的螢幕尺寸

這類文章可能已經不是新鮮事,但這篇文章裡面有個更重要的寶物,也就是本文作者開發用來協助觀察螢幕大小,margins,適合閱讀區域導引,與 Dynamic Type 尺寸的 app:Adaptivity,有相關需求的讀者不妨考慮購入。


🤪 Pofat 選推

Zonble 在上週 CocoaHeads Taipei 的 Flutter 演講

Twitter avatar for @zonble
zonble 🍺 ゾンビル 4H111 @zonble
本日抬槓內容: 1. Flutter Forward 摘要 2. 怎樣在 Flutter App 中使用 Google Maps
youtube.comFeb. 2023 可可頭直播|CocoaHeads Taipei聚會日期:2023/2/9--Hello, World.We are CocoaHeads Taipei!更多 CocoaHeads Taipei: https://www.cocoaheads.tw/
5:04 PM ∙ Feb 9, 2023
17Likes1Retweet

ChatGPT is a Blury JPEG of the Web 這篇文章上週很熱門,原因無它,就是寫得太好,簡單卻精準的類比最近 AI 浪潮其本質

Twitter avatar for @kaosensei_1412
K 先生 @kaosensei_1412
我擅自猜想姜要說的是:「小朋友,別隨隨便便就大驚小怪,取代人類沒那麼簡單,認真生活、認真感受,更刺激的還在後面。」(N/N) ​
readwise.ioChatGPT Is a Blurry JPEG of the Web | annotated by EricIn 2013, workers at a German construction company noticed something odd about their Xerox photocopier: when they made a copy of the floor plan of a house, the copy differed from the original in a subtle but significant way.
3:52 PM ∙ Feb 11, 2023
97Likes15Retweets

Meta 上週的新論文也點出了一個更未來的演進方向,能自造輪子的 Toolformer

Twitter avatar for @Tisoga
Jiayuan @Tisoga
1/ 把 Meta 前两天发布的这篇论文读了一遍,mind blowing 这篇论文被近期 ChatGPT & Bing Chat 的风头盖过去了,不过我感觉论文中提到的内容可能是未来 Language Model 发展的一个重要的分支。 -- thread 🧵 --
Image
11:00 PM ∙ Feb 11, 2023
2,011Likes602Retweets

只是想分享溫馨小故事,為對應通膨和寒冬景氣,老任逆勢加薪啊

Twitter avatar for @GearoidReidy
Gearoid Reidy リーディー・ガロウド @GearoidReidy
It's all well and good getting excited about Nintendo increasing wages 10%, but most people don't work for Nintendo, or a company like it. Nintendo has incredibly strong pricing power; it's sub-sub-contractors don't.
bloomberg.comBloomberg - Are you a robot?
1:42 AM ∙ Feb 8, 2023
18Likes4Retweets

Surprise, madafaka

Twitter avatar for @PR0GRAMMERHUM0R
Programmer Humor @PR0GRAMMERHUM0R
Isn't C++ fun? reddit.com/r/programmerhu…
Image
5:00 PM ∙ Feb 8, 2023
4,609Likes772Retweets

復古風就是每隔數年會襲捲一次的流行,見證仿真 Switch 吧

Twitter avatar for @MaxxFrazer
Max @MaxxFrazer
I’ve been updating the touch interactions of the Switch in #RealityUI. Instead of just “click to toggle”, it now handles a variety of cases depending on whether you touch the thumb or the background. Would you prefer this or are there any missing edge cases? #RealityKit
9:43 PM ∙ Feb 10, 2023
13Likes2Retweets

我心亦若是

Twitter avatar for @PR0GRAMMERHUM0R
Programmer Humor @PR0GRAMMERHUM0R
Finally reddit.com/r/programmerhu…
Image
9:00 AM ∙ Feb 9, 2023
6,287Likes781Retweets
Share this post

波報 #33 - 蒼天無情

pofat.substack.com
Comments
TopNewCommunity

No posts

Ready for more?

© 2023 Pofat
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing