Post

Replies

Boosts

Views

Activity

Reply to view sheet on first launch
Hi Claude31I re-jigged a bit of code around to the following:struct ContentView: View { @State private var showingSheet = true var body: some View { RequestHome().sheet(isPresented: $showingSheet) { RegisterHome() } } }This gives me the effect I was trying to achieve - a sheet display on launch which I'll conditionalize later on.Craig
Dec ’19
Reply to Optional Protocol Type
Thanks for the reply. Fixed the typo. The implementation of id and name are immutable once the instance has been created. If I undersrtand your answer UserData would be:final class UserData: ObservableObject, Codable { var account: AProfile? }Is that what you mean?
Feb ’20
Reply to Checking is Biometry is Enrolled
You need to evaluate policy first to determine if biometry is available. var biometryType: LABiometryType { var error: NSError? let context = LAContext() guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else { return .none     }     return context.biometryType } // Test the biometry type switch self.biometryType { case .faceID: print("Face ID")     case .touchID: print("Touch ID")     case .none: print("None")     @unknown default: print("Unknown") }
Jun ’21
Reply to Semaphore Wait After Creating UIButton
@OOPer7 that's exactly what's happening! So do you have another suggestion to achieve the experience of waiting to the user to interact with the button before continuing the onDisplay function? I tried using a UIAlertViewController being a model dialog but couldn't find a way to make the dialog appear - probably the same issue with DispatchSemaphore(value: 0). Many thanks!
Jun ’21
Reply to UserDefaults on App Launch
Hi I have a LaunchViewController which is set as the initial view controller on the storyboard. The LaunchViewController checks a key in the UserDefaults then either navigates to the user licence or the welcome screen. class LaunchViewController: UIViewController { override func viewDidLoad() {     super.viewDidLoad() var viewControllerIdentifier = "Welcome" let storyboard = UIStoryboard(name: "Main", bundle: nil) // Check if the user agreement has been accepted. if !UserDefaults.standard.bool(forKey: "HasAchnowledgedUserLicence") { viewControllerIdentifier = "UserLicence" }       let viewController = storyboard.instantiateViewController(identifier: viewControllerIdentifier) navigationController?.pushViewController(viewController, animated: true)     } } As the user progresses through the app and needs to go back the Welcome screen, I execute this code: _ = navigationController?.popToRootViewController(animated: false)` If you think I should be setting the root view controller instead of performing a navigation as in: window?.rootViewController = viewConntoller window?.makeKeyAndVisible() Many thanks for helping
Aug ’21
Reply to SecItemAdd with kSecAttrAccessControl Error
Hi Quinn Thanks for the reply. I removed kSecAttrSynchronizable added kSecUseDataProtectionKeychain. For now, I also removed kSecAttrAccessible as part of the initial query. Here is the refactored code: public func addItem(value: Data, forKey: String, accessControlFlags: SecAccessControlCreateFlags? = nil) { guard !forKey.isEmpty else {     return    } var query: [String: Any] = [kSecClass as String: kSecClassGenericPassword, kSecAttrService as String: Bundle.main.bundleIdentifier!, kSecAttrAccount as String: forKey, kSecValueData as String: value, kSecUseDataProtectionKeychain as String: true] // Check if any access control is to be applied. if let accessControlFlags = accessControlFlags { var error: Unmanaged<CFError>?       guard let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, kSecAttrAccessibleWhenUnlockedThisDeviceOnly, accessControlFlags, &error) else { return } query[kSecAttrAccessControl as String] = accessControl    } let status = SecItemAdd(query as CFDictionary, nil) guard status != errSecDuplicateItem else { return } guard status == errSecSuccess else { let message = SecCopyErrorMessageString(status, nil) as String? ?? "Unknown error" print(message) return } } And to invoke the function: try? addItem(value: "Hello World", forKey: "greeting", accessControlFlags: [.userPresence]) The error which occurs in both the simulator and device is -25293 The user name or passphrase you entered is not correct. Appreciate if you have any guidance on this one... Thanks
Sep ’21
Reply to HStack Alignments
@robnotyou, thanks for replying. I'm trying to achieve making the HStack full width with the image and the VStack text in both containers leading aligned. Because of the text size difference it's slight off.
Dec ’21
Reply to HStack Alignments
After some more trial and error I finally got the look I was after. HStack padding seemed to cause the issue. Here is the final result. import SwiftUI struct ContentView: View {     var body: some View {         VStack(alignment: .center, spacing: 64) {             Text("About My Data")                 .font(.title)                 .fontWeight(.heavy)                 .multilineTextAlignment(.center)                 .padding()             VStack(alignment: .leading, spacing: 32) {                 HStack {                     Image(systemName: "network")                             .font(.system(size: 36.0))                             .foregroundColor(.blue)                     VStack(alignment: .leading) {                        Text("Network Support")                         .font(.headline)                         .fontWeight(.bold)                     Text("Download your data from anywhere.")                         .font(.body)                         .foregroundColor(.gray)                     }                 }                 HStack {                     Image(systemName: "hand.raised.fill")                         .font(.system(size: 36.0))                         .foregroundColor(.blue)                     VStack(alignment: .leading) {                         Text("Data Privacy")                         .font(.headline)                         .fontWeight(.bold)                     Text("Scanned certificates are never stored on the device.")                         .font(.body)                         .foregroundColor(.gray)                     }                 }             }         }.padding()     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } }
Dec ’21
Reply to XCTest Ambiguous type name
I managed to get the errors to go away. I "unchecked" DefaultValue+Extension.swift and DefaultValuePropertyWrapper.swift from being part of the test target and in the DefaultValueTest.swift file replaced @testable import MyFramework with import MyFramework. Compiles and the tests run successfully now 😅
Jan ’22