Posts

Post not yet marked as solved
2 Replies
147 Views
Please take a look at the following simple SwiftUI View: struct ContentView: View { var body: some View { ForEach(1...1, id: \.self) { i in subview(i) } } func subview(_ i: Int) -> some View { print("creating subview \(i)") return Text("Hello, world!") } } When this View is displayed, all subviews are created twice, as the print statements show. (Unfortunately the Apple Developer Forums UI does not let me attach my sample Xcode project.) This happens on macOS 14.4.1. Am I doing something wrong or is this a SwiftUI bug? (In a real-world application the View creation can be expensive…)
Posted
by rx8.
Last updated
.
Post not yet marked as solved
0 Replies
140 Views
According to my experiments SwiftData does not work with model attributes of primitive type UInt64. More precisely, it crashes in the getter of a UInt64 attribute invoked on an object fetched from the data store. With Core Data persistent UInt64 attributes are not a problem. Does anyone know whether SwiftData will ever support UInt64?
Posted
by rx8.
Last updated
.
Post not yet marked as solved
4 Replies
764 Views
My little Swift program on macOS 12.3.1 creates a cryptographic key for a symmetric cipher as follows: let parameters = NSMutableDictionary() var raw = 256 let num = CFNumberCreate(kCFAllocatorDefault, .sInt32Type, &raw)! var optError: Unmanaged<CFError>? parameters.setValue("Pix Cipher", forKey: kSecAttrLabel as String) parameters.setValue(kSecAttrKeyTypeAES, forKey: kSecAttrKeyType as String) parameters.setValue(num, forKey: kSecAttrKeySizeInBits as String) parameters.setValue(kCFBooleanTrue, forKey: kSecAttrIsPermanent as String) parameters.setValue(kCFBooleanTrue, forKey: kSecAttrCanEncrypt as String) parameters.setValue(kCFBooleanTrue, forKey: kSecAttrCanDecrypt as String) key = SecKeyGenerateSymmetric(parameters, &optError) This key can be stored in the Key Chain and works fine for encryption and decryption. But when I want to export it using var error: Unmanaged<CFError>? let cfData = SecKeyCopyExternalRepresentation(key!, &error) , this fails, with error set to something like Error Domain=NSOSStatusErrorDomain Code=-4 "MacOS error: -4" What does "MacOS error: -4" mean? (kCFMessagePortTransportError/kCSIdentityDeletedErr /unimpErr?) Why does SecKeyCopyExternalRepresentation not work? What is wrong with the key? Kind regards, Jakob
Posted
by rx8.
Last updated
.