Post

Replies

Boosts

Views

Activity

Reply to 'UIStoryboard' and 'UIStoryboardSegue' was deprecated in visionOS 1.0 - Why?
When my destination is 'visionOS Designed for iPad', I get no errors and no warnings. But my tabs are now at the bottom and not on the left side. It's okay to use a Storyboard and StoryboardSegue with visionOS if it's run as an iPad app, but not as a standalone app. It doesn't make sense to me at all. Oh yeah, interface builder products are being deprecated as well.
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’23
Reply to SwiftData Aggregation
import SwiftData @Model public class Person { var name: String var age: Int init(name: String, age: Int) { self.name = name self.age = age } } You'll probably want to do the below differently. The below ViewController is just given to you for ideas. import UIKit import SwiftData class ViewController: UIViewController { var container: ModelContainer? var context: ModelContext? override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. do { let schema = Schema([Person.self]) let modelConfig = ModelConfiguration(schema: schema, cloudKitDatabase: .private("iCloud.com.yourcompany.ClassStats")) container = try ModelContainer(for: schema, configurations: [modelConfig]) if let container = container { context = ModelContext(container) context?.autosaveEnabled = true } } catch { print(error) } } func getStats() { let minAge = 20 let maxAge = 40 let predicate = #Predicate<Person> { person in person.age >= minAge && person.age <= maxAge } let sortBy = [SortDescriptor<Person>(\.name)] var descriptor = FetchDescriptor<Person>(predicate: predicate, sortBy: sortBy) if let persons = try? context?.fetch(descriptor), persons.count > 0 { let count = persons.count } } }
Aug ’23
Reply to SwiftData Predicate Issue
I actually have found a workaround. Here it is. let predicate = #Predicate<Data> { data in data.result == result && data.variable?.starts(with: SomeString) ?? false } Note the data.variable?. and the ?? false. This works. I still don't think I should have to discover these things. Something needs to be fixed on Apple's end.
Aug ’23
Reply to 'UIStoryboard' and 'UIStoryboardSegue' was deprecated in visionOS 1.0 - Why?
When my destination is 'visionOS Designed for iPad', I get no errors and no warnings. But my tabs are now at the bottom and not on the left side. It's okay to use a Storyboard and StoryboardSegue with visionOS if it's run as an iPad app, but not as a standalone app. It doesn't make sense to me at all. Oh yeah, interface builder products are being deprecated as well.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’23
Reply to SwiftData Aggregation
import SwiftData @Model public class Person { var name: String var age: Int init(name: String, age: Int) { self.name = name self.age = age } } You'll probably want to do the below differently. The below ViewController is just given to you for ideas. import UIKit import SwiftData class ViewController: UIViewController { var container: ModelContainer? var context: ModelContext? override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. do { let schema = Schema([Person.self]) let modelConfig = ModelConfiguration(schema: schema, cloudKitDatabase: .private("iCloud.com.yourcompany.ClassStats")) container = try ModelContainer(for: schema, configurations: [modelConfig]) if let container = container { context = ModelContext(container) context?.autosaveEnabled = true } } catch { print(error) } } func getStats() { let minAge = 20 let maxAge = 40 let predicate = #Predicate<Person> { person in person.age >= minAge && person.age <= maxAge } let sortBy = [SortDescriptor<Person>(\.name)] var descriptor = FetchDescriptor<Person>(predicate: predicate, sortBy: sortBy) if let persons = try? context?.fetch(descriptor), persons.count > 0 { let count = persons.count } } }
Replies
Boosts
Views
Activity
Aug ’23
Reply to SwiftData Predicate Issue
I actually have found a workaround. Here it is. let predicate = #Predicate<Data> { data in data.result == result && data.variable?.starts(with: SomeString) ?? false } Note the data.variable?. and the ?? false. This works. I still don't think I should have to discover these things. Something needs to be fixed on Apple's end.
Replies
Boosts
Views
Activity
Aug ’23