狂人山庄 Madman Hills
  • Home
  • About Me
  • 『罩.片』
Sign in Subscribe

SwiftUI

A collection of 2 posts
SwiftUI

Swift读取RSA Key报错RSA private key creation from data failed

macOS Swift程序因为需要,使用了RSA非对称加密。读取公钥的时候一切正常,但读取私钥的时候会报错 Error Domain=NSOSStatusErrorDomain Code=-50 "RSA private key creation from data failed" (paramErr: error in user parameter list) UserInfo={numberOfErrorsDeep=0, NSDescription=RSA private key creation from data failed} 相关代码片段如下 func loadPrivateKey(from string: String) -> SecKey? { guard let data = Data(base64Encoded:
2024年3月26日 1 min read
SwiftUI

@StateObject和@ObservedObject的区别

@ObservedObject创建的对象,会在View重绘的时候重新创建。@StateObject创建的对象不会,只会创建一次,所以在视图重建的时候不会受到影响。 比如 @ObservedObject var downloader = Downloader() // ... @StateObject var downloader = Downloader() VStack { ProgressView(value: downloader.progress.fractionCompleted) .progressViewStyle(LinearProgressViewStyle()) Text("\(Int(downloader.progress.fractionCompleted * 100))%") Button(action: { downloader.cancelDownload() isDownloading = false }) { Text("Cancel") }
2023年7月15日 1 min read
Page 1 of 1
狂人山庄 Madman Hills © 2025
Powered by Ghost