Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Locking View Rotation
When Apple implements a SwiftUIController to manage SwiftUI views ... just kidding. You need to implement an AppDelegate with the prefered interface orientations and set it as the app delegate for your swift ui application, hopefully it should work: class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { .portrait } } Then in your swiftui @main app import UIKit import SwiftUI @main struct SampleApp: App { @UIApplicationDelegateAdaptor var appDelegate: AppDelegate var body: some Scene { ... } } With some work, you can begin to architect updates between the AppDelegate and the SwiftUI App into the SwiftUI Environment for all views to have whatever data you will need.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’23
Reply to Xcode 15, how to uncheck "Connect via network" for physical device?
On an AnyConnect VPN setup, disabling Bluetooth, WIFI, and Data has no effect unless you disconnect the VPN. Making this thing exclusive to the network is crazy. What if all this traffic leaves the local network before reaching its internal point-to-point target because of how a given network is configured? USB 3+ and Thunderbolt 2+ are more reliable in the form of a cable connection. If it's not broken, don't change it.
Dec ’23
Reply to How to translate data from c language void * pointer to [UInt8 ] in swift code.
Anything that's not declared within the struct is deallocated from the stack when set data returns. typedef struct { uint8_t *memo; uint8_t array[5]; int why[4]; char *books; } Bounce; implemenation of fix. void fix(Bounce *model) { memset(model->array,0x53,5); model->why[0] = 2; model->why[1] = 3; model->why[2] = 2; model->why[3] = 2; model->books = "Hello world"; model->memo = model->array; } import Foundation var bounce = Bounce() fix(&bounce) bounce.books.map({print(String(cString: $0))}) for value in 0..<5 { print(bounce.memo.advanced(by: value).pointee) } let why = bounce.why print(why) Output: Hello world 83 83 83 83 83 (2, 3, 2, 2) Program ended with exit code: 0 With the void* or anonymous type. typedef struct { void *memo; uint8_t array[5]; int why[4]; char *books; } Bounce; for value in 0..<5 { let thing = bounce.memo.assumingMemoryBound(to: UInt8.self).advanced(by: value).pointee print(thing) }
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’23