Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

SwiftData deleteRules & uniqueness
Hello everyone, How do I need to handle the delete with the relationship deny? When I delete a model that still has a reference to another model, it deletes it from the UI. But when I re-run the simulator, it's back again. Does someone have a hint for me? How is it possible to ensure the uniqueness of the entries? Because I saw that the Attribute unique can't be used with CloudKit.
1
0
823
Apr ’24
Reply to AppleScript: Error -1728 "Messages got an error: Can’t get service of item 1 of every text chat."
hmmm... Actually text chat should inherit properties from chat anyway - whether it should also inherit responses too, I'm not sure. Your script works on my 10.10.4 - but you already know that...But where text chat is identified by name, chat is identified by id. What does:tell application Messages to accept item 1 in chatsandtell application Messages to return connection status of service of item 1 in chatsyield?
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’15
SwiftData with two Stores
Hi, has anybody managed to get two sqlite stores working? If I define the stores with a configuration for each it seems like that only the first configuration and and therefore the store is recognised. This is how I define the configuration and container: import SwiftData @main struct SwiftDataTestApp: App { var modelContainer: ModelContainer init() { let fullSchema = Schema([ SetModel.self, NewsModel.self ]) let setConfiguration = ModelConfiguration( setconfig, schema: Schema([SetModel.self]), url: FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent(Sets.sqlite), readOnly: false) let newsConfiguration = ModelConfiguration( newsconfig, schema: Schema([NewsModel.self]), url: FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!.appendingPathComponent(News.sqlite), readOnly: false) modelContainer = try! ModelContainer(for: fullSchema, configurations: [setConfiguration,newsConfiguration]) } var body: some Scene { WindowGroup { Conten
5
0
3.5k
Aug ’23
Reply to Chaining instead of overriding Compiler Arguments with Config files
That makes sense but defining a new variable for each path and ensuring the target to include all the include path could be buggy. It would be nice if the config file supports a different assignment operator (~=for instance)likeHEADER_SEARCH_PATHS ~= $(inherited) /myownpaths/ (for append in the end) or HEADER_SEARCH_PATHS =~ $(inherited) /myownpaths/ (for preappend)so the values are appended instead of overwriting.For now will try defining the variables and using that in the target.
Jan ’18
Equivalent of NSManagedObjectContext.existingObject in SwiftData?
CoreData contexts expose a very convenient existingObject API that allows to fallback to retrieve from the persistent store in case the object is not registered in the context yet. I don't see any equivalent in SwiftData. Does that mean we should fallback to fetch methods instead? Is there any rationale behind the lack of this API other than that it's still in development. For more details about what I'm trying to do. I have a read-only context (the main context) and a read-write context. After inserting a model in the read-write context (and saving), I'd like to retrieve the equivalent object from the read-only context.
1
0
705
Jun ’23
SwiftData equivalent of NSFetchedResultsController
As far as I can tell, there’s no equivalent to Core Data’s NSFetchedResultsController in SwiftData. It would be very helpful to have a way to respond to sets of changes in a ModelContext outside of a SwiftUI view. For instance, this is very helpful when using a Model-View-ViewModel architecture. The @Query property wrapper is great for use in a SwiftUI view, but sometimes it’s helpful to process data outside of the view itself. The fetch() method on ModelContext is helpful for one-time operations, but as far as I can't tell it doesn't address receiving changes on an ongoing basis. Am I missing some equivalent for this use case? Also filed as feedback FB12288916
2
0
2.2k
Jun ’23
Share Extension Lifetime and SwiftData
I have an app that uses a Share Extension that allows the user to share videos, from Files and Photos etc., the video URL and some related data is then persisted with SwiftData and synchronized with CloudKit. This code has worked consistently for a long time although recently, with iOS 26 and recent builds of iOS 18, I have observed that the video is either not saved to SwiftData (iOS 26.0), or available locally when the app is opened on the same device where the share occurred, but not synchronized to other devices (iOS 18.7 and iOS 26.1 beta). Assuming the video is opened locally after being shared into the app, it is typically synchronized with CloudKit to other devices although it's not as reliable as it should be. Is there a reliable approach in the Share Extension to ensure that the data is saved to the local SwiftData database and then synchronized with CloudKit. I suspect it could be that the lifetime of the Share Extension has become even more constrained in recent OS updat
1
0
194
Oct ’25
Reply to Core Data - How to delete ONLY the relationship link between 2 entities
Thank You to Joakim Danielson on StackOverflow ! The answer was there... I just wasn't aware... Core Data creates a func for the entity relationship. As an example, entity Students has a relationship named Classes (destination = Classes entity) entity Classes has a relationship named Students (destination = Students entity) Core Data creates a func for each of the entity relationships: .removeFromClasses() .removeFromStudents() these remove the relationship link from each of the respective relationships. In order to remove the relationship completely, I execute both func - the entity objects both remain but are no longer linked !
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Protocol-oriented architecture
I'm not sure if I understood correctly. So both ItemCollection and PointCollection should inherit from another protocol that does not have a Self or associated type constraints? So does the same apply to the Match protocol if I want to use it from match controller? It can't have Self or associated type constraints?var match: Match = TennisMatch(participants: [player1, player2) //Error now because Match inherits from ItemCollection
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’15
ShieldConfigurationExtension & SwiftData
Hi, I am developing a Screen Time App and I am having issues with the ShieldConfigurationExtension (ShieldConfigurationDataSource). I know this extensions is sandboxed but I should be able to read data from the main app. I am using SwiftData as my database, but I am unable to initialize it in the extensions with an error indicating insufficient file permissions. I have App Group set up and I am able to share data using UserDefaults but that is just inconvenient. Is there any way I could just open the SwiftData in read only mode so that I could display the user some info on the shield? SwiftData Init: private func setupContainer() throws { let schema = Schema([ DogEntity.self, HouseEntity.self ]) // Use app group container if available let config: ModelConfiguration if let containerURL = FileManager.default.containerURL( forSecurityApplicationGroupIdentifier: group.(Bundle.app.bundleIdentifier ?? ) ) { config = ModelConfiguration(schema: schema, url: containerURL.appendingPathCompone
1
0
195
May ’25
SwiftData - Load the data into Apps
I am developing Tasty Recipes app. I want to load all data related to this app such Recipe Category, Recipes List, Recipes Inscredient, Preparation Methods and so on. How can I load and store all data using SwiftData. User is going to use these data. They will update few things like Favourite Recipes, Rating. How can I do this.
2
0
912
Feb ’24
SwiftData deleteRules & uniqueness
Hello everyone, How do I need to handle the delete with the relationship deny? When I delete a model that still has a reference to another model, it deletes it from the UI. But when I re-run the simulator, it's back again. Does someone have a hint for me? How is it possible to ensure the uniqueness of the entries? Because I saw that the Attribute unique can't be used with CloudKit.
Replies
1
Boosts
0
Views
823
Activity
Apr ’24
Reply to Custom images/dots in UIPageControl
You can only change UIPageControl's indicator tint color. I would make a custom class inherited from the UIControl.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Oct ’15
Reply to Why after pod install throw that error?
I had a $(inherited) but recursive, just change it to non-recursive project target -> build settings -> framework_search_path
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to AppleScript: Error -1728 "Messages got an error: Can’t get service of item 1 of every text chat."
hmmm... Actually text chat should inherit properties from chat anyway - whether it should also inherit responses too, I'm not sure. Your script works on my 10.10.4 - but you already know that...But where text chat is identified by name, chat is identified by id. What does:tell application Messages to accept item 1 in chatsandtell application Messages to return connection status of service of item 1 in chatsyield?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’15
SwiftData with two Stores
Hi, has anybody managed to get two sqlite stores working? If I define the stores with a configuration for each it seems like that only the first configuration and and therefore the store is recognised. This is how I define the configuration and container: import SwiftData @main struct SwiftDataTestApp: App { var modelContainer: ModelContainer init() { let fullSchema = Schema([ SetModel.self, NewsModel.self ]) let setConfiguration = ModelConfiguration( setconfig, schema: Schema([SetModel.self]), url: FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent(Sets.sqlite), readOnly: false) let newsConfiguration = ModelConfiguration( newsconfig, schema: Schema([NewsModel.self]), url: FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!.appendingPathComponent(News.sqlite), readOnly: false) modelContainer = try! ModelContainer(for: fullSchema, configurations: [setConfiguration,newsConfiguration]) } var body: some Scene { WindowGroup { Conten
Replies
5
Boosts
0
Views
3.5k
Activity
Aug ’23
Reply to Chaining instead of overriding Compiler Arguments with Config files
That makes sense but defining a new variable for each path and ensuring the target to include all the include path could be buggy. It would be nice if the config file supports a different assignment operator (~=for instance)likeHEADER_SEARCH_PATHS ~= $(inherited) /myownpaths/ (for append in the end) or HEADER_SEARCH_PATHS =~ $(inherited) /myownpaths/ (for preappend)so the values are appended instead of overwriting.For now will try defining the variables and using that in the target.
Replies
Boosts
Views
Activity
Jan ’18
Equivalent of NSManagedObjectContext.existingObject in SwiftData?
CoreData contexts expose a very convenient existingObject API that allows to fallback to retrieve from the persistent store in case the object is not registered in the context yet. I don't see any equivalent in SwiftData. Does that mean we should fallback to fetch methods instead? Is there any rationale behind the lack of this API other than that it's still in development. For more details about what I'm trying to do. I have a read-only context (the main context) and a read-write context. After inserting a model in the read-write context (and saving), I'd like to retrieve the equivalent object from the read-only context.
Replies
1
Boosts
0
Views
705
Activity
Jun ’23
SwiftData equivalent of NSFetchedResultsController
As far as I can tell, there’s no equivalent to Core Data’s NSFetchedResultsController in SwiftData. It would be very helpful to have a way to respond to sets of changes in a ModelContext outside of a SwiftUI view. For instance, this is very helpful when using a Model-View-ViewModel architecture. The @Query property wrapper is great for use in a SwiftUI view, but sometimes it’s helpful to process data outside of the view itself. The fetch() method on ModelContext is helpful for one-time operations, but as far as I can't tell it doesn't address receiving changes on an ongoing basis. Am I missing some equivalent for this use case? Also filed as feedback FB12288916
Replies
2
Boosts
0
Views
2.2k
Activity
Jun ’23
Reply to UIConfigurationStateCustomKey with UIContentView.
Thanks for the answer! I am using UICollectionView.CellRegistration. So seems like I need to inherit from UICollectionViewListCell with code from documentation.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to How do we know which CNContainer represents iCloud?
Maybe iCloud inherits the traditional title of AddressBook syncing service since MobileMe (or .Mac?).
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’15
Share Extension Lifetime and SwiftData
I have an app that uses a Share Extension that allows the user to share videos, from Files and Photos etc., the video URL and some related data is then persisted with SwiftData and synchronized with CloudKit. This code has worked consistently for a long time although recently, with iOS 26 and recent builds of iOS 18, I have observed that the video is either not saved to SwiftData (iOS 26.0), or available locally when the app is opened on the same device where the share occurred, but not synchronized to other devices (iOS 18.7 and iOS 26.1 beta). Assuming the video is opened locally after being shared into the app, it is typically synchronized with CloudKit to other devices although it's not as reliable as it should be. Is there a reliable approach in the Share Extension to ensure that the data is saved to the local SwiftData database and then synchronized with CloudKit. I suspect it could be that the lifetime of the Share Extension has become even more constrained in recent OS updat
Replies
1
Boosts
0
Views
194
Activity
Oct ’25
Reply to Core Data - How to delete ONLY the relationship link between 2 entities
Thank You to Joakim Danielson on StackOverflow ! The answer was there... I just wasn't aware... Core Data creates a func for the entity relationship. As an example, entity Students has a relationship named Classes (destination = Classes entity) entity Classes has a relationship named Students (destination = Students entity) Core Data creates a func for each of the entity relationships: .removeFromClasses() .removeFromStudents() these remove the relationship link from each of the respective relationships. In order to remove the relationship completely, I execute both func - the entity objects both remain but are no longer linked !
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to Protocol-oriented architecture
I'm not sure if I understood correctly. So both ItemCollection and PointCollection should inherit from another protocol that does not have a Self or associated type constraints? So does the same apply to the Match protocol if I want to use it from match controller? It can't have Self or associated type constraints?var match: Match = TennisMatch(participants: [player1, player2) //Error now because Match inherits from ItemCollection
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’15
ShieldConfigurationExtension & SwiftData
Hi, I am developing a Screen Time App and I am having issues with the ShieldConfigurationExtension (ShieldConfigurationDataSource). I know this extensions is sandboxed but I should be able to read data from the main app. I am using SwiftData as my database, but I am unable to initialize it in the extensions with an error indicating insufficient file permissions. I have App Group set up and I am able to share data using UserDefaults but that is just inconvenient. Is there any way I could just open the SwiftData in read only mode so that I could display the user some info on the shield? SwiftData Init: private func setupContainer() throws { let schema = Schema([ DogEntity.self, HouseEntity.self ]) // Use app group container if available let config: ModelConfiguration if let containerURL = FileManager.default.containerURL( forSecurityApplicationGroupIdentifier: group.(Bundle.app.bundleIdentifier ?? ) ) { config = ModelConfiguration(schema: schema, url: containerURL.appendingPathCompone
Replies
1
Boosts
0
Views
195
Activity
May ’25
SwiftData - Load the data into Apps
I am developing Tasty Recipes app. I want to load all data related to this app such Recipe Category, Recipes List, Recipes Inscredient, Preparation Methods and so on. How can I load and store all data using SwiftData. User is going to use these data. They will update few things like Favourite Recipes, Rating. How can I do this.
Replies
2
Boosts
0
Views
912
Activity
Feb ’24