Search results for

“SwiftData inheritance relationship”

4,981 results found

Post

Replies

Boosts

Views

Activity

Outlets do not work correctly with ViewControllers that inherit from the framework's ViewController
I am creating and selling a third-party SDK. The framework includes a subclass of UIViewController named BaseViewController. I also provide the subclass of BaseViewController (ChildViewController) as *.swift source code and xib file to be integrated into the application along with the *.framework. I encountered an issue during this integration. I cannot access the view property of the parent class UIViewController from .xib file of the ChildViewController which is integrated into the application. Please advise me on how to avoid this issue. I have prepared specific source code and screenshots. I will attach them and send them in a subsequent email.
0
0
530
Dec ’23
Core Data relationship question
I'm looking to understand the connection between relationships in core data. What I'm trying to do is store two entities 'Workout' and 'Exercise' and allow multiple 'Exercises' to one 'Workout'. Im'm coming from a MYSQL background so it's a little fuzzy when it comes to the relation.How would I be able to keep the reference to the workout object, use some variable to store the objectID and then use it to update the exercise entity?Thanks
1
0
429
Dec ’16
How this code works? ViewController inherits from another ViewController it's viewDidLoad func
I found a solution for an issue that I was having to get a SwipeGestureRecognizer to work. And this was the solution: ViewController1 class ViewController1: ViewController2 { // This ViewController // has access to the functionality // declared in viewDidLoad() method // from ViewController2. } ViewController2 class ViewController2: UIViewController { override func viewDidLoad() { let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(_:))) swipeRight.direction = .right let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(_:))) swipeLeft.direction = .left let swipeUp = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(_:))) swipeUp.direction = .up let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(_:))) swipeDown.direction = .down view.addGestureRecognizer(swipeRight) view.addGestureRecognizer(swipeLeft) view.addGestureRecognizer(swipeUp) view.addGestureRe
4
0
1k
Apr ’21
CoreData array as attribute vs relationship
I recently started to learn CoreData with CloudKit in SwiftUI. It seems to be still quite a young solution (I know CoreData itself has been around for over a decade), so apart from some limited resources within the official documentation and archive, I get most information from the web. One thing that I had trouble with was storing in CoreData moderately complex data received in JSON format. Although I read that CoreData itself is not a relational database, it does look much alike to me, so my first choice would be to use relationships, but I saw people store arrays of data using attributes instead, e.g., in this StackOverflow thread. In my case, it would be an array of custom datatype objects, and while some resources on the web were helpful to get me quite far (e.g. this), I couldn't pull it off in the end. My question after this long background story is — in what situations would I choose attributes for storing collections of data instead of relationships? As an example, I currently have
0
0
688
May ’23
Proper Setup for Library to inherit Privacy Settings from iOS Info.plist to its references
I've written a small swift library for discovering ssdp devices and created a swift package for this. This library uses another library (BlueSocket) as dependency for the socket communication. https://github.com/devmkdd/TinySSDP Now I wanted to use this library within my iOS application and did add it as SPM dependency. For the Simulator everything is fine, on the real iOS14 device I get some problems which led (to me) to a strange behavior (As ssdp is used within the local network I've added the NSLocalNetworkUsageDescription property to my info.plist). I would expect, everything to work after the user has granted this permissions. But the BlueSocket library (the dependency used by my own library) seems not have access to the local network (no route to host). The really strange behavior for me now starts at the following point. To exclude problems within my code, I've moved over all of my library code and included it directly within the Xcode project. The BlueSocket Library is now referenced from my Xcode Pr
0
0
454
Dec ’20
Reply to SwiftData relationships — are they really areas?
I've just discovered today that I'm seeing non-order-preserving behavior, despite using a stored array as the to-many model relationship property. Others are also discovering this issue. See here: Swift forums I haven't investigated duplicate insertion behavior. Order-preserving behavior is critical for my app as well. I haven't seen any indication in the SwiftData docs or API that this is intended behavior, so I'll be filing a bug report and looking for workarounds in the meantime. I hope you do as well!
Jul ’23
SwiftData + CloudKit
I have a new app I’m working on. I just ran the app on my own phone and noting was put in CloudKit. I get the following error: com.apple.coredata.cloudkit.zone:__defaultOwner__ = }> So none of my SwiftData models are being transferred up the CloudKit. My bundle ID is: com.tazmancoder.MyHomeInventory. I know that everything is setup correctly cause I have another app using SwiftData and I followed the same setup. I have done the following and nothing has worked: Go to https://developer.apple.com and sign in Select Certificates, Identifiers & Profiles Select Identifiers (App IDs) Edit App ID for the app Uncheck iCloud Save Check iCloud Quit Xcode and Clear DerivedData Run app I am not sure why this is happening? Can someone please tell me why this happening and how to fix it? Thanks, -Mark/*
0
0
555
Aug ’24
SwiftData not syncing with iCloud
Hello everyone, I followed this (https://www.hackingwithswift.com/quick-start/swiftdata/how-to-sync-swiftdata-with-icloud) guide from Paul Hudson on how to sync swiftdata with iCloud. I tried it on my device directly and it worked exactly as I would expect. Now I tried the same version of the app on another device installed through TestFlight external tester group. It no longer works. When deleting the app, the alert reads Deleting this app will also delete its data, but any documents or data will be stored in iCloud will not be deleted so the app should have said something in iCloud. When looking in Settings -> Your Name -> iCloud -> Manage Account Storage, on the working device I can see around 300 KB saved in iCloud, on the other device my app is not listed. Both have a fast and working internet connection, almost fully charged, low data mode turned off, running 17.4.1, Background modes enabled, Mobile data enabled, more than enough unused iCloud storage and plenty of ti
2
0
3.2k
Mar ’24
Reply to Command Line Utility vs. Core Bluetooth Permissions
FWIW, the culprit is the missing inherited permissions. When running the tool from iTerm (which is what I'm using as terminal emulator), it inherits the permissions from it. Granting Bluetooth permissions to iTerm fixes my problem. Now: Is it possible that my command line program can detect this lack of (inherited) permission, thus preventing the crash and rather showing an instruction alert instead?
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’21
Sharing data with SwiftData
Hi, I have an app that uses Core Data + CloudKit, and which allows sharing of entities with other iCloud users. It works in a manner similar to the sample application provided on the Apple developer site. Is this use case supported with SwiftData? The ability to share data with other iCloud users is fundamental to my app, so I cannot migrate to SwiftData unless this functionality is provided.
3
0
2.8k
Jun ’23
Reply to calling a convenience initializer from subclass
I found a way to do the job. If I want to inherit superclass's convenience initializer in a subclass, I have to follow the rule 1 and 2 as been introduced in heading Automatic initializer inheritence, in the swift programming manual. More specially,“Rule 1If your subclass doesn’t define any designated initializers, it automatically inherits all of its superclass designated initializers.Rule 2If your subclass provides an implementation of all of its superclass designated initializers—either by inheriting them as per rule 1, or by providing a custom implementation as part of its definition—then it automatically inherits all of the superclass convenience initializers.”Excerpt From: Apple Inc. “The Swift Programming Language (Swift 3).” iBooks
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’16
How to setup SwiftData in a Widget
So I have been trying to add a widget to my app. I am trying to add SwiftData to sync data from my app to the widget. My attempt at doing that is shown below: import SwiftData import SwiftUI import WidgetKit @main struct CubeSpeedWidgetBundle: WidgetBundle { let fullSchema = Schema([Time.self, Session.self]) let configuration = ModelConfiguration(schema: Schema([Time.self, Session.self]), inMemory: false, readOnly: false, cloudKitDatabase: .automatic) var body: some Widget { CubeSpeedWidget() .modelContainer(try! ModelContainer(for: fullSchema, configurations: [configuration])) CubeSpeedWidgetLiveActivity() } } Xcode says that Value of type 'CubeSpeedWidget' has no member 'modelContainer'. How should I do this properly? Thanks.
1
0
2.2k
Jul ’23
Outlets do not work correctly with ViewControllers that inherit from the framework's ViewController
I am creating and selling a third-party SDK. The framework includes a subclass of UIViewController named BaseViewController. I also provide the subclass of BaseViewController (ChildViewController) as *.swift source code and xib file to be integrated into the application along with the *.framework. I encountered an issue during this integration. I cannot access the view property of the parent class UIViewController from .xib file of the ChildViewController which is integrated into the application. Please advise me on how to avoid this issue. I have prepared specific source code and screenshots. I will attach them and send them in a subsequent email.
Replies
0
Boosts
0
Views
530
Activity
Dec ’23
Illegal attempt to establish a relationship problem.
I pass a object from another viewcontroller and try to add a new record on coredata, object is not nil , but I got the error message below, why? What is that mean in different contexts?'NSInvalidArgumentException', reason: 'Illegal attempt to establish a relationship 'schedule' between objects in different contexts
Replies
3
Boosts
0
Views
7.1k
Activity
Oct ’15
Core Data relationship question
I'm looking to understand the connection between relationships in core data. What I'm trying to do is store two entities 'Workout' and 'Exercise' and allow multiple 'Exercises' to one 'Workout'. Im'm coming from a MYSQL background so it's a little fuzzy when it comes to the relation.How would I be able to keep the reference to the workout object, use some variable to store the objectID and then use it to update the exercise entity?Thanks
Replies
1
Boosts
0
Views
429
Activity
Dec ’16
SwiftData Equivalent of @SectionedFetchRequest
Hi all, Has anyone stumbled upon the SwiftData equivalent of @SectionedFetchRequest? Is there a way to do it with @Query? I'll keep going through the documentation but if anyone has an answer, it would be much appreciated!! Thank you.
Replies
5
Boosts
0
Views
2.5k
Activity
Jun ’23
How this code works? ViewController inherits from another ViewController it's viewDidLoad func
I found a solution for an issue that I was having to get a SwipeGestureRecognizer to work. And this was the solution: ViewController1 class ViewController1: ViewController2 { // This ViewController // has access to the functionality // declared in viewDidLoad() method // from ViewController2. } ViewController2 class ViewController2: UIViewController { override func viewDidLoad() { let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(_:))) swipeRight.direction = .right let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(_:))) swipeLeft.direction = .left let swipeUp = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(_:))) swipeUp.direction = .up let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(respondToSwipeGesture(_:))) swipeDown.direction = .down view.addGestureRecognizer(swipeRight) view.addGestureRecognizer(swipeLeft) view.addGestureRecognizer(swipeUp) view.addGestureRe
Replies
4
Boosts
0
Views
1k
Activity
Apr ’21
CoreData array as attribute vs relationship
I recently started to learn CoreData with CloudKit in SwiftUI. It seems to be still quite a young solution (I know CoreData itself has been around for over a decade), so apart from some limited resources within the official documentation and archive, I get most information from the web. One thing that I had trouble with was storing in CoreData moderately complex data received in JSON format. Although I read that CoreData itself is not a relational database, it does look much alike to me, so my first choice would be to use relationships, but I saw people store arrays of data using attributes instead, e.g., in this StackOverflow thread. In my case, it would be an array of custom datatype objects, and while some resources on the web were helpful to get me quite far (e.g. this), I couldn't pull it off in the end. My question after this long background story is — in what situations would I choose attributes for storing collections of data instead of relationships? As an example, I currently have
Replies
0
Boosts
0
Views
688
Activity
May ’23
Proper Setup for Library to inherit Privacy Settings from iOS Info.plist to its references
I've written a small swift library for discovering ssdp devices and created a swift package for this. This library uses another library (BlueSocket) as dependency for the socket communication. https://github.com/devmkdd/TinySSDP Now I wanted to use this library within my iOS application and did add it as SPM dependency. For the Simulator everything is fine, on the real iOS14 device I get some problems which led (to me) to a strange behavior (As ssdp is used within the local network I've added the NSLocalNetworkUsageDescription property to my info.plist). I would expect, everything to work after the user has granted this permissions. But the BlueSocket library (the dependency used by my own library) seems not have access to the local network (no route to host). The really strange behavior for me now starts at the following point. To exclude problems within my code, I've moved over all of my library code and included it directly within the Xcode project. The BlueSocket Library is now referenced from my Xcode Pr
Replies
0
Boosts
0
Views
454
Activity
Dec ’20
Reply to SwiftData relationships — are they really areas?
I've just discovered today that I'm seeing non-order-preserving behavior, despite using a stored array as the to-many model relationship property. Others are also discovering this issue. See here: Swift forums I haven't investigated duplicate insertion behavior. Order-preserving behavior is critical for my app as well. I haven't seen any indication in the SwiftData docs or API that this is intended behavior, so I'll be filing a bug report and looking for workarounds in the meantime. I hope you do as well!
Replies
Boosts
Views
Activity
Jul ’23
SwiftData + CloudKit
I have a new app I’m working on. I just ran the app on my own phone and noting was put in CloudKit. I get the following error: com.apple.coredata.cloudkit.zone:__defaultOwner__ = }> So none of my SwiftData models are being transferred up the CloudKit. My bundle ID is: com.tazmancoder.MyHomeInventory. I know that everything is setup correctly cause I have another app using SwiftData and I followed the same setup. I have done the following and nothing has worked: Go to https://developer.apple.com and sign in Select Certificates, Identifiers & Profiles Select Identifiers (App IDs) Edit App ID for the app Uncheck iCloud Save Check iCloud Quit Xcode and Clear DerivedData Run app I am not sure why this is happening? Can someone please tell me why this happening and how to fix it? Thanks, -Mark/*
Replies
0
Boosts
0
Views
555
Activity
Aug ’24
SwiftData not syncing with iCloud
Hello everyone, I followed this (https://www.hackingwithswift.com/quick-start/swiftdata/how-to-sync-swiftdata-with-icloud) guide from Paul Hudson on how to sync swiftdata with iCloud. I tried it on my device directly and it worked exactly as I would expect. Now I tried the same version of the app on another device installed through TestFlight external tester group. It no longer works. When deleting the app, the alert reads Deleting this app will also delete its data, but any documents or data will be stored in iCloud will not be deleted so the app should have said something in iCloud. When looking in Settings -> Your Name -> iCloud -> Manage Account Storage, on the working device I can see around 300 KB saved in iCloud, on the other device my app is not listed. Both have a fast and working internet connection, almost fully charged, low data mode turned off, running 17.4.1, Background modes enabled, Mobile data enabled, more than enough unused iCloud storage and plenty of ti
Replies
2
Boosts
0
Views
3.2k
Activity
Mar ’24
Reply to Command Line Utility vs. Core Bluetooth Permissions
FWIW, the culprit is the missing inherited permissions. When running the tool from iTerm (which is what I'm using as terminal emulator), it inherits the permissions from it. Granting Bluetooth permissions to iTerm fixes my problem. Now: Is it possible that my command line program can detect this lack of (inherited) permission, thus preventing the crash and rather showing an instruction alert instead?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Mar ’21
Sharing data with SwiftData
Hi, I have an app that uses Core Data + CloudKit, and which allows sharing of entities with other iCloud users. It works in a manner similar to the sample application provided on the Apple developer site. Is this use case supported with SwiftData? The ability to share data with other iCloud users is fundamental to my app, so I cannot migrate to SwiftData unless this functionality is provided.
Replies
3
Boosts
0
Views
2.8k
Activity
Jun ’23
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
Reply to calling a convenience initializer from subclass
I found a way to do the job. If I want to inherit superclass's convenience initializer in a subclass, I have to follow the rule 1 and 2 as been introduced in heading Automatic initializer inheritence, in the swift programming manual. More specially,“Rule 1If your subclass doesn’t define any designated initializers, it automatically inherits all of its superclass designated initializers.Rule 2If your subclass provides an implementation of all of its superclass designated initializers—either by inheriting them as per rule 1, or by providing a custom implementation as part of its definition—then it automatically inherits all of the superclass convenience initializers.”Excerpt From: Apple Inc. “The Swift Programming Language (Swift 3).” iBooks
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’16
How to setup SwiftData in a Widget
So I have been trying to add a widget to my app. I am trying to add SwiftData to sync data from my app to the widget. My attempt at doing that is shown below: import SwiftData import SwiftUI import WidgetKit @main struct CubeSpeedWidgetBundle: WidgetBundle { let fullSchema = Schema([Time.self, Session.self]) let configuration = ModelConfiguration(schema: Schema([Time.self, Session.self]), inMemory: false, readOnly: false, cloudKitDatabase: .automatic) var body: some Widget { CubeSpeedWidget() .modelContainer(try! ModelContainer(for: fullSchema, configurations: [configuration])) CubeSpeedWidgetLiveActivity() } } Xcode says that Value of type 'CubeSpeedWidget' has no member 'modelContainer'. How should I do this properly? Thanks.
Replies
1
Boosts
0
Views
2.2k
Activity
Jul ’23