Post

Replies

Boosts

Views

Activity

Reply to Refactoring withUnsafeMutableBytes
You can re-write it like this:     let result = randomIV.withUnsafeMutableBytes {(bufPointer: UnsafeMutableRawBufferPointer) in         SecRandomCopyBytes(kSecRandomDefault, bufPointer.count, bufPointer.baseAddress!)     } Or a little more simply:     let result = randomIV.withUnsafeMutableBytes {         SecRandomCopyBytes(kSecRandomDefault, $0.count, $0.baseAddress!)     }
Apr ’22
Reply to NaviagtionBar item doesn't appear
You should do it in a content view controller of the UINavigationController. SecondViewController.swift import UIKit class SecondViewController: UINavigationController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground self.viewControllers = [RootViewController()] } } RootViewController.swift import UIKit class RootViewController: UIViewController { override func viewDidLoad() { title = "Decount timers" super.viewDidLoad() view.backgroundColor = .systemBackground navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(didTapAddButton)) } @objc func didTapAddButton(_ sender: Any) { //... } }
Jan ’22
Reply to What is dynamic shared object (DSO) handle that #dsohandle applies to in Swift?
Searching with swift dsohandle, I can find a few discussions. https://twitter.com/chriseidhof/status/722352741767639040?lang=en https://github.com/apple/swift-log/issues/72 https://youtrack.jetbrains.com/issue/OC-14546 Estimating from the descriptions, dynamic shared object seems to be representing the dynamically linked libraries such as .dylib or .so currently running. It may be useful for the authors of libraries using dynamically linked libraries, where they can add a little more info for logging inside the libraries, but not so useful for usual developers just using the libraries.
Jan ’22
Reply to Failed to produce diagnostic for expression in SwiftUI, XCode 13.2
You should better include clear sentences explaining what you want to ask here. Have you come here to just report your bug? Or want to find a solution to fix the bug? Anyway, your code lacks one pair of parentheses at about 32nd line: VStack(alignment: .center, spacing: 10) { Text("Computers Choice: \(options[computersChoice].name)") .fontWeight(.bold) .padding //<- Image("\(options[computersChoice].name)") .resizable() .frame(width: 100, height: 100) .padding() Text("You need to \(winOrLose ? "Win" : "Lose")") .fontWeight(.bold) } So, you need to fill parentheses there: VStack(alignment: .center, spacing: 10) { Text("Computers Choice: \(options[computersChoice].name)") .fontWeight(.bold) .padding() //<- Image("\(options[computersChoice].name)") .resizable() .frame(width: 100, height: 100) .padding() Text("You need to \(winOrLose ? "Win" : "Lose")") .fontWeight(.bold) } Usual compilers can detect where this sort of simple syntax error is occurring, you can send a bug report to swift.org as suggested.
Jan ’22