- Sukai Lab - 程式設計

= Note =

Terminal 尋找空資料夾

因為需求需要將Mac中一些空的資料夾刪除,但因為資料夾在Mac中並不會顯示大小,因此無法判斷是否為空的資料夾,以下提供了簡單的方法達到這樣的需求。

Shell Terminal macOS 終端機

繼續閱讀

SwiftUI 如何讓 List 中的 Button 正常運行

目前要在SwiftUI中加入Button 到 List中,會導致點擊不正常,若只有一個按鈕倒是沒什麼問題,整個欄位點擊就會對應那個單一按鈕促發的事件。但今天的情況如果是需要一個以上的按鈕呢?

這時候問題就來了! 這種情況下,點擊表格就會無法準確指定要促發哪個按鈕。一般來說,網路上都會推薦您使用Foreach的方式去呈現,沒錯,這樣確實能讓每個按鈕都正常運作,但是當資料量到一個程度這將導致效能大幅下降,明顯呈現畫面延遲,因此最後還是得回到List。那今天要怎麼解決這個問題呢?簡單!請看!

SwiftUI ButtonStyle PlainButtonStyle List

繼續閱讀

Swift 播放音效或震動提示使用者吧! 增加使用體驗

在某些時候我們要提示使用者他已經點擊了按鈕,或是觸發某些事件時,一個方式是透過介面呈現文字或動畫,另外一個方式就是透過播放簡單的音效,甚至是震動來達到效果,這樣一點點的效果也會增加使用者的使用感受度喔~

AudioServicesPlaySystemSound AudioToolbox

繼續閱讀

Let's Encrypt更新失敗 Renew Faield

Let's Encrypt的憑證有效時間為三個月,因此每三個月要做憑證更新,但是在憑證更新時遇到 Attempting to renew cert from..... Could not connect to xxxxxxx.id Skipping. 等問題時要如何解決呢?

Nginx Let's Encrypt 憑證更新

繼續閱讀

Swift 一秒學會進制轉換,真的一秒沒在騙

在開發藍牙設備經常需要對設備做命令,這時候就要透過十六進制包裝成Data送出,但進制轉換表一般人才不會去背,因此這時候就需要點"簡單"的方法!

Swift iOS Binary Decimal Hexadecimal

繼續閱讀

在Swift中要如何解析json資料?透過Codable輕鬆辦到!

在iOS的開發中時常需要透過JSON檔案做資料交換,這個時候可以使用Codable做到這一點。Codable可以解析JSON檔案也可以快速的將文字包裝成JSON檔。

Codable is a type alias for the Encodable and Decodable protocols. When you use Codable as a type or a generic constraint, it matches any type that conforms to both protocols.

Swift JSON Codable CodingKeys

繼續閱讀

iOS 開發 Swift 透過FileManager取得App中的文件路徑

在iOS的開發中有時候需要對本地文件(iOS內部)操作,這時候可以透過 FileManager取得我們想要的資料。FileManager不僅可以讓我們做到查詢資料,還可以對這些資料文件做刪除修改。

A file manager object lets you examine the contents of the file system and make changes to it. The FileManager class provides convenient access to a shared file manager object that is suitable for most types of file-related manipulations. A file manager object is typically your primary mode of interaction with the file system. You use it to locate, create, copy, and move files and directories. You also use it to get information about a file or directory or change some of its attributes.

FileManager iOS Swift

繼續閱讀