iOS9 Swift File Creating NSFileManager.createDirectoryAtPath with NSURL

I figured this one out. createDirectoryAtPath() is unable to process a path with the “file://” prefix. To get a path without the prefix you must use path() or relativePath(). let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]) let logsPath = documentsPath.URLByAppendingPathComponent(“logs”) do { try NSFileManager.defaultManager().createDirectoryAtPath(logsPath.path!, withIntermediateDirectories: true, attributes: nil) } catch let error as NSError { … Read more

Using a MTLTexture as the environment map of a SCNScene

Lighting SCN Environment with an MTK texture Using Xcode 13.3.1 on macOS 12.3.1 for iOS 15.4 app. The trick is, the environment lighting requires a cube texture, not a flat image. Create 6 square images for MetalKit cube texture in Xcode Assets folder create Cube Texture Set place textures to their corresponding slots mirror images … Read more

Call to main actor-isolated instance method XXX in a synchronous nonisolated context

This is bug in current swift versions as compiler is not able to recognize the global actor context for a defer block, the discussion for this is going on swift forum and a PR with fix also available that should resolve this issue in future swift versions. For now, explicitly global actor context need to … Read more

didSet for a @Binding var in Swift

Instead of didSet you can always use onReceive (iOS 13+) or onChange (iOS 14+): import Combine import SwiftUI struct ContentView: View { @State private var counter = 1 var body: some View { ChildView(counter: $counter) Button(“Increment”) { counter += 1 } } } struct ChildView: View { @Binding var counter: Int var body: some View … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)