Issue with optional Core Data relationship using NSPersistentCloudKitContainer - swift

I am using NSPersistentCloudKitContainer, not sure if that's the cause of my issue or CloudKit generic behaviour. The sync setup works fine so far. I am now adding a new feature, causing some an issue:
I have an entity Item, which can be put in a Group. Relation in CD is to-one and optional. Works fine on device: I can set and remove group, everything is persisted.
But CloudKit just ignores when I remove the group. It does not complain, just ignores it. No matter if remove happens from Item, Groups or both sides. On next download it’s back in a group. Is it just a bug in NSPersistentCloudKitContainer? It’s possible to nil fields on CloudKit records, right?
What I see in CloudKit dashboard:
• Group field on Item is of type String.
• A fresh Item record, never assigned to a group, does not have the group field.
• As soon as it gets a group field, I can’t get rid of it. Emptying the value causes to crash.
When I get the CloudKit record on device, it does not even have the group field. So I can't manually reset it. It only shows the Group field in the CloudKit dashboard. I guess the container handles the relationship internally and only maps it during sync.
Is there any way to properly handle this?

Related

qlik sense error in published dashboard that does not appear in edit mode

I built a dashboard in Qlik Sense and after I published it I noticed the following error -
"Invalid sort order in properties".
When I duplicate the dashboard in order to edit it, the error drops and the data is shown correctly.
What could be the issue?
Had similar issue some time back. In my case the object was an extension and it was trying to modify (apply some patches) to the underlying object. As in your case it was working fine if the app is not published. The reason was that once the app is published you don't have the permission to modify objects that are published.
Modify objects on published apps is forbidden by default. It can be overwritten by changing one of the default security rules but personally I will not advise you to change the security rule because it will be applied to all published apps (unless you change the security rule to target only set of apps)

How to set the Assigned To when state changes in VSTS/Azure DevOps

I have an inherited process from an Agile process. The base process had the following states New, Active, Resolved, Completed. I added several new states, so now it goes New, Triaged, Active, Development Dont, IT Testing Done, Resolved, Confirmed, Completed to better match how it flows through different people.
The process has some built in State change rules, so when it goes from New to Resolved or Active to Resolved the Assigned To changes back to the Created By person. Also when it goes from Resolved back to Active it switches the assigned to back to the Resolved By user. This works fine, the problem that I have is that these state change rules only happen for these specific states.
In VSTS online I have setup some custom rules to do different things as it moves between different states, but what I can't find a way to do is to set the Assigned To field to some other person field on the Work Item. I can set it to a hard coded person, but that is not what I want. I want to do the same state change rules that already exist for the built in states on my new states.
Here is an example of some of the rules that I have set, but I cannot find a way to set the Assigned to field to another field, i.e. Created By or Resolved By.
Use the copy value from to assign the value of one field to another:
I've just been doing a similar thing and found there's also an action setting to 'Use the current user to set the value of...'
Example of this below:

Swift/Firebase add only new data [duplicate]

According to Firebase docs:
ChildAdded is triggered once for each existing child and then again every time a new child is added to the specified path
So, I have an app, that has a little banner at the top that pops up every time a user gets a new message. As you could have guessed, these messages are stored in a child in the user object in Firebase. So, here's the problem, when I load the app, it pops up for EVERY message the user has. Is it possible to have this observe event ONLY be called when a new child is added? I don't want it to be triggered for every single existing child, only when a new one is added. I would hate to have to store message references in core data, and do a check for every child to see if it already exists in core data :/
A few ways to do this:
Use ref.queryLimitedToLast(1) when you start. See Firebase, only get new children.
keep track of the most recent key you've got in your local storage and then query with queryOrderByKey().queryStartingAtValue(latestKey)
Add a timestamp to the items and then queryOrderByChild("timestamp").queryStartingAt(now) for items with timestamp >= now. See how to discard initial data in a Firebase DB

Core Data - Changing attributes type

I have a project and I am using core data.
I have some entities, with attributes. When I started the project I choose some atributes and now I want to change their types (Int to String for example). ANd so I did it.
THe thing is, I am getting errors...
I checked the code, I think every thing is ok.
I even deleted the entire entity and made a new one with some name but it doesn't work.
How can I change it with success?
You can use code data migration for this by creating new version..
To change data types you need to create a new version of the database, you can not just simply modifie it because that way your users would have to delete and redownload your app every time you change something.
Here you can read how to do this.
The simulator or device you are running the app on still 'remembers' the old type and data. Simply hold down on the app and press the 'X' to delete it. When you press play in XCode it will reinstall the app with the new data types.

Debugging SIGABRT within NSManagedObjectContext -save:

From inside NSManagedObjectContext -save: I am getting this message:
Assertion failed: (_Unwind_SjLj_Resume() can't return), function _Unwind_SjLj_Resume, file /SourceCache/libunwind/libunwind-24.1/src/Unwind-sjlj.c, line 326.
Program received signal: “SIGABRT”.
warning: Unable to read symbols for
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1
(8C148)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib
(file not found).
This happens when I delete an Experiment object with to-many with Run which has to-many with Sample which has to-one with Data. Experiment also has to-many with Page which has to-many with Display which has to-many to Run. I mention this to point out the cyclical nature of the graph. Here is a simplified graph of model:
An Experiment a top level entity with which the user interacts. An Experiment contains multiple Run objects. A Run is a collection of data starting at a particular time and ending at a later time. Since data can be collected from multiple sources simultaneously, there is a Sample for each source for each Run. An Experiment contains data and this data needs to be viewed and interacted with. So, each Experiment has some number of Page objects and each Page contains some number of Displays (e.g., graphs, meters). A Display is configured to display some subset of the Runs that belong to the Experiment. So, while an Experiment may contains dozens of Runs, one of its Pages will only display a few of those Runs at a time. The Display entity maintains this list. A Display is not a view. A view will reference a Display object and be notified of changes to the Display object.
I had been using Delete Rules but have now switched to "No Action" delete rules in combination with -prepareForDeletion methods for all of these classes. This change made no difference. In both cases, the error message is the same.
Interestingly, when I relaunch the app, all the objects that were marked for deletion have been deleted.
Also, if an Experiment has no Run objects, then deletion works without incidence. For that matter, deleting a single Run from an Experiment also works.
I am hoping that someone has seen something like this and can offer advice on what would cause this. Or, if someone has advice on how to get libXcodeDebuggerSupport.dylib for iOS 4.2.1, that might also be helpful.
Update: I followed advice found here and was able to get Xcode to find libXcodeDebuggerSupport.dylib for iOS 4.2.1. But this did not help at all in diagnosing problem - which persists.
Update 2: After reading a bit and downloading a version of unwind-sjlj.c, it seems that I am dealing with something like an uncaught exception. I am not sure how this helps me...
Update 3: Thanks to Kamchatka, I did something I probably should have done a few days ago: turned on "Stop on Objective-C Exceptions". This allowed me to see that a reference to a deleted object was still being held - and, worse, was key-value observing the deleted object. Fixing this fixed problem and I was able to revert to using delete rules rather than -prepareForDeletion methods.
You should try to activate "Run > Stop on Objective-C exception". It allowed me to find the place where there was an access to an object turned into fault which was the root cause of the problem.