Search results for

“SwiftData inheritance relationship”

4,981 results found

Post

Replies

Boosts

Views

Activity

Inherit&expose public api from static lib dependency.
Hi everyone, I have to build a framework that has a staticLib as dependency. In the same time I want to use some classes from staticLib via framework's public api and it isn't accessible even if I import framework - I tested with otool and nm tools and the symbols seems to be in framework but inaccessible. How to make public classes from staticLib to be accessible from framework api ? Any hint or advice would be welcome, thanks in advance.
1
0
591
Feb ’22
Can child processes inherit Info.plist properties of a parent app (such as LSSupportsGameMode)?
My high-level goal is to add support for Game Mode in a Java game, which launches via a macOS launcher app that runs the actual java game as a separate process (e.g. using the java command line tool). I asked this over in the Graphics & Games section and was told this, which is why I'm reposting this here. I'm uncertain how to speak to CLI tools and Java games launched from a macOS app. These sound like security and sandboxing questions which we recommend you ask about in those sections of the forums. The system seems to decide whether to enable Game Mode based on values in the Info.plist (e.g. for LSApplicationCategoryType and GCSupportsGameMode). However, the child process can't seem to see these values. Is there a way to change that? (The rest of this post is copied from my other forums post to provide additional context.) Imagine a native macOS app that acts as a launcher for a Java game.** For example, the launcher app might use the Swift Process API or a similar method to run the java command line t
3
0
377
Jun ’25
Is this a SwiftData migration ?
I know if i change existing properties in a @Model it’s a migration. However if I add a new @Model class(es) that has no relationships to any existing is that still a migration or am i free to add? if free to add, should i create a new model container or can I just add the new Model classes ?
0
0
556
May ’24
Reply to SwiftData does not retrieve my inverse one-to-many Relationship
Your code actually throws the following error when saving the context (if you add do...try... catch for context.save()) SwiftData.DefaultStore save failed with error: Error Domain=NSCocoaErrorDomain Code=1570 %{PROPERTY}@ is a required value. UserInfo={NSValidationErrorObject= (entity: ThirdModel; id: 0x60000028c520 ; data: { name = my third model; parent = nil; }), NSLocalizedDescription=%{PROPERTY}@ is a required value., NSValidationErrorKey=parent, NSValidationErrorValue=null} To avoid the error, change the to-one relationship to Optional. Also, when declaring a relationship, use var because SwiftData maintains it for you. If you declare your models in the following way, your code will work: final public class SecondModel { var parent: FirstModel? ... } @Model final public class ThirdModel { var parent: SecondModel? ... }
Topic: Programming Languages SubTopic: Swift Tags:
May ’24
SwiftData Question
As I am new to programming in Swift, I have a question about SwiftData if you are writing a program and created your model and done some testing and realize you need to add something to your model that you missed during the initial setup do you have to start a whole new project? As I noticed when adding in something new to the model the project can't find the original SwiftData? Thread 1: Fatal error: failed to find a currently active container for User
4
0
1.2k
May ’24
SwiftData does not cascade delete
Even if there are one-many relationship models with the cascade delete rule, SwiftData does not cascade delete items. For example, there is one school has multiple students like the following models, and even when the school is deleted, the students in the school are not deleted. This happens when a user create a school and students and delete the school immediately. Are there any workarounds for now? @Model final class School { var name: String @Relationship(deleteRule: .cascade, inverse: Student.school) var students: [Student] = [] init(name: String) { self.name = name } } @Model final class Student { var fullName: String var school: School init(fullName: String, school: School) { self.fullName = fullName self.school = school } }
10
0
3.2k
Oct ’23
Reply to required keyword, initializers, and class inheritance
You need to read the Language Guide more carefully.Firstly, there are conditions for automatic inheritance of an initializer. If the conditions are met a subclass inherits the initializer. If not it does not.Secondly, the Guide says clearly: You do not have to provide an explicit implementation of a required initializer if you can satisfy the requirement with an inherited initializer.So you need to implement the initializer if you cannot inherit an initializer from the superclass, or if the inherited initilizer would not do exactly what you want.Jan E.
Topic: Programming Languages SubTopic: Swift Tags:
May ’16
Reply to SwiftData data crashes with @Relationship
The stack trace seems to indicate that your code was trying to retrieve the value of an attribute, but the attribute didn't exist in the SwiftData model. The code snippet shows that TrainInfo and StopStation is a to-many relationship, which has nothing wrong. isOrigin and isStarting seem to be an attribute of StopStation. They are not included in your code snippet, and so I can't comment. Overall, the information you provided doesn't seem to be enough to diagnose the issue... Best, —— Ziqiao Chen  Worldwide Developer Relations.
Apr ’25
Many-to-one relationship can't be unlinked
I am using NSPersistentCloudKitContainer, and have a many-to-one optional relationship, let say many item to one project.This relationship is optional, so I can do this ->item.project = nilwhen the user decided that this item does not belongs to any project.This code is fine in Core Data, and the inverse relationships are updated accordingly.However, once this gets synced to CloudKit, and come back down, the project relationship will be restored. Setting the project to other entities are fine, it just cannot be set to nil.Playing with the CloudKit dashboard, I realized that the schema that is created have a CD_Project as String. If I create a new item without any project, there's no such field, however, once I assign a project to an item, the field is set, and there is no way to unset this field, even from the CloudKit Dashboard. I naively tried to clear out the string in cloudkit dashboard but it crashes my app when the sync happens.Is this a bug that will be fixed? The
3
0
1.4k
Jan ’20
The app contains or inherits from non-public classes in Frameworks
Getting this error from itunes connect while uploading app to appstore.Xcode version - 9.4.1
Replies
0
Boosts
0
Views
1.3k
Activity
Aug ’18
Inherit&expose public api from static lib dependency.
Hi everyone, I have to build a framework that has a staticLib as dependency. In the same time I want to use some classes from staticLib via framework's public api and it isn't accessible even if I import framework - I tested with otool and nm tools and the symbols seems to be in framework but inaccessible. How to make public classes from staticLib to be accessible from framework api ? Any hint or advice would be welcome, thanks in advance.
Replies
1
Boosts
0
Views
591
Activity
Feb ’22
Can child processes inherit Info.plist properties of a parent app (such as LSSupportsGameMode)?
My high-level goal is to add support for Game Mode in a Java game, which launches via a macOS launcher app that runs the actual java game as a separate process (e.g. using the java command line tool). I asked this over in the Graphics & Games section and was told this, which is why I'm reposting this here. I'm uncertain how to speak to CLI tools and Java games launched from a macOS app. These sound like security and sandboxing questions which we recommend you ask about in those sections of the forums. The system seems to decide whether to enable Game Mode based on values in the Info.plist (e.g. for LSApplicationCategoryType and GCSupportsGameMode). However, the child process can't seem to see these values. Is there a way to change that? (The rest of this post is copied from my other forums post to provide additional context.) Imagine a native macOS app that acts as a launcher for a Java game.** For example, the launcher app might use the Swift Process API or a similar method to run the java command line t
Replies
3
Boosts
0
Views
377
Activity
Jun ’25
Relationship Between CLEF and CLAP Atoms
CLEF and CLAP atoms in Quicktime files have a similar purpose as it relates to the display dimensions of a video image. Can someone clarify for me the relationship between these two atoms? How does a media player know which one to use as the reference for display dimensions?
Replies
0
Boosts
0
Views
297
Activity
Oct ’19
Is this a SwiftData migration ?
I know if i change existing properties in a @Model it’s a migration. However if I add a new @Model class(es) that has no relationships to any existing is that still a migration or am i free to add? if free to add, should i create a new model container or can I just add the new Model classes ?
Replies
0
Boosts
0
Views
556
Activity
May ’24
Reply to SwiftData does not retrieve my inverse one-to-many Relationship
Your code actually throws the following error when saving the context (if you add do...try... catch for context.save()) SwiftData.DefaultStore save failed with error: Error Domain=NSCocoaErrorDomain Code=1570 %{PROPERTY}@ is a required value. UserInfo={NSValidationErrorObject= (entity: ThirdModel; id: 0x60000028c520 ; data: { name = my third model; parent = nil; }), NSLocalizedDescription=%{PROPERTY}@ is a required value., NSValidationErrorKey=parent, NSValidationErrorValue=null} To avoid the error, change the to-one relationship to Optional. Also, when declaring a relationship, use var because SwiftData maintains it for you. If you declare your models in the following way, your code will work: final public class SecondModel { var parent: FirstModel? ... } @Model final public class ThirdModel { var parent: SecondModel? ... }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’24
Consider landing SwiftData to Server?
Is it possible to deploy SwiftData to server? Or is it a good direction to consider improve SwiftData?
Replies
0
Boosts
0
Views
463
Activity
Apr ’24
SwiftData Question
As I am new to programming in Swift, I have a question about SwiftData if you are writing a program and created your model and done some testing and realize you need to add something to your model that you missed during the initial setup do you have to start a whole new project? As I noticed when adding in something new to the model the project can't find the original SwiftData? Thread 1: Fatal error: failed to find a currently active container for User
Replies
4
Boosts
0
Views
1.2k
Activity
May ’24
Reply to Instance member cannot be used on type in ARKitVision example
It inherits from StatusViewController which inherits from UIViewController.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’18
How to use transformable in SwiftData?
Did anyone successfully used transformable in SwiftData to store UIColor or SwiftUI Color type? @Attribute(.transformable) var color: UIColor
Replies
6
Boosts
0
Views
4.9k
Activity
Jun ’23
SwiftData does not cascade delete
Even if there are one-many relationship models with the cascade delete rule, SwiftData does not cascade delete items. For example, there is one school has multiple students like the following models, and even when the school is deleted, the students in the school are not deleted. This happens when a user create a school and students and delete the school immediately. Are there any workarounds for now? @Model final class School { var name: String @Relationship(deleteRule: .cascade, inverse: Student.school) var students: [Student] = [] init(name: String) { self.name = name } } @Model final class Student { var fullName: String var school: School init(fullName: String, school: School) { self.fullName = fullName self.school = school } }
Replies
10
Boosts
0
Views
3.2k
Activity
Oct ’23
SwiftData and SpotLight Search
Hi all, has anybody found the trick how to get SwiftData working with SpotLight Search? Setting the attribute spotlight in the Model definition seems to do nothing at all, as pointed out by Paul Hudson in his new book as well (https://www.hackingwithswift.com/quick-start/swiftdata/how-to-index-swiftdata-objects-in-spotlight) Thanks a lot!
Replies
3
Boosts
0
Views
1.1k
Activity
Oct ’23
Reply to required keyword, initializers, and class inheritance
You need to read the Language Guide more carefully.Firstly, there are conditions for automatic inheritance of an initializer. If the conditions are met a subclass inherits the initializer. If not it does not.Secondly, the Guide says clearly: You do not have to provide an explicit implementation of a required initializer if you can satisfy the requirement with an inherited initializer.So you need to implement the initializer if you cannot inherit an initializer from the superclass, or if the inherited initilizer would not do exactly what you want.Jan E.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’16
Reply to SwiftData data crashes with @Relationship
The stack trace seems to indicate that your code was trying to retrieve the value of an attribute, but the attribute didn't exist in the SwiftData model. The code snippet shows that TrainInfo and StopStation is a to-many relationship, which has nothing wrong. isOrigin and isStarting seem to be an attribute of StopStation. They are not included in your code snippet, and so I can't comment. Overall, the information you provided doesn't seem to be enough to diagnose the issue... Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Apr ’25
Many-to-one relationship can't be unlinked
I am using NSPersistentCloudKitContainer, and have a many-to-one optional relationship, let say many item to one project.This relationship is optional, so I can do this ->item.project = nilwhen the user decided that this item does not belongs to any project.This code is fine in Core Data, and the inverse relationships are updated accordingly.However, once this gets synced to CloudKit, and come back down, the project relationship will be restored. Setting the project to other entities are fine, it just cannot be set to nil.Playing with the CloudKit dashboard, I realized that the schema that is created have a CD_Project as String. If I create a new item without any project, there's no such field, however, once I assign a project to an item, the field is set, and there is no way to unset this field, even from the CloudKit Dashboard. I naively tried to clear out the string in cloudkit dashboard but it crashes my app when the sync happens.Is this a bug that will be fixed? The
Replies
3
Boosts
0
Views
1.4k
Activity
Jan ’20