手電筒App送審中。

小賢 發表在 痞客邦 留言(0) 人氣()

 

defaults delete com.torusknot.SourceTreeNotMAS "NSSplitView Subview Frames repowindow_LogViewDescSplitter"

 

小賢 發表在 痞客邦 留言(0) 人氣()

結論:

小賢 發表在 痞客邦 留言(0) 人氣()

  func print(_ items: Any...) 為主要的Function,需放置全域的位置 (外層不能有東西)

func print(_ items: Any...)
{
    #if DEBUG
        for item in items
        {
            print(item, separator: " ", terminator: "\n")
        }
    #endif
}

public struct Utilities
{
    public static func openSafari(_ urlString: String) {
        
        guard let urlEncoded = urlString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) else {
            print("無法URL Encode, \(#function): urlString")
            return
        }
        
        guard let url = URL(string: urlEncoded) else {
            print("無法轉換成URL, \(#function): urlString")
            return
        }
        
        UIApplication.shared.open(url)
    }
}

  接下來就能在其它地方照常使用print輸出,而Release Mode,print內的#if DEBUG包住的地方將不會被編譯而變成Empty Function,這時Swift Compiler將會把function call整個拿掉,似乎是完美的作法。

小賢 發表在 痞客邦 留言(0) 人氣()

[UWP] 在進入背景或進入前景時,觸發OnNavigatedTo, OnNavigatedFrom。

  每個Page都會有自己的進入頁面跟離開頁面的邏輯,有時會希望App進入背景 or 進入前景時也能夠呼叫到目前頁面的 OnNavigatedTo, OnNavigatedFrom,但預設是不會被呼叫的,

小賢 發表在 痞客邦 留言(0) 人氣()