Update only some attributes of an entity
up vote
0
down vote
favorite
I'm new to Core Data and I would like to update only some attributes of an entity that may or may not yet exist in the store.
What I'm currently doing is inserting a new entity with only a few fields set, but afterwards I find that the other attributes have been reset to nil on entities for which those attributes have already been set.
I am using a merge policy of NSMergeByPropertyObjectTrumpMergePolicy
which I believe would overwrite only the attributes I have set on my latest update.
I would like to avoid a complicated approach of first obtaining the entity, and then doing a field-by-field reset using old values.
core-data
add a comment |
up vote
0
down vote
favorite
I'm new to Core Data and I would like to update only some attributes of an entity that may or may not yet exist in the store.
What I'm currently doing is inserting a new entity with only a few fields set, but afterwards I find that the other attributes have been reset to nil on entities for which those attributes have already been set.
I am using a merge policy of NSMergeByPropertyObjectTrumpMergePolicy
which I believe would overwrite only the attributes I have set on my latest update.
I would like to avoid a complicated approach of first obtaining the entity, and then doing a field-by-field reset using old values.
core-data
If you are always inserting a new entity, you are creating multiple entities. How do you make sure that you are updating the existing entity? Can you show your code?
– Mike Taverne
Nov 24 at 0:45
I have a constraint on an attribute in the entity that ensures uniqueness based on that attribute,
– andrewz
Nov 24 at 1:22
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm new to Core Data and I would like to update only some attributes of an entity that may or may not yet exist in the store.
What I'm currently doing is inserting a new entity with only a few fields set, but afterwards I find that the other attributes have been reset to nil on entities for which those attributes have already been set.
I am using a merge policy of NSMergeByPropertyObjectTrumpMergePolicy
which I believe would overwrite only the attributes I have set on my latest update.
I would like to avoid a complicated approach of first obtaining the entity, and then doing a field-by-field reset using old values.
core-data
I'm new to Core Data and I would like to update only some attributes of an entity that may or may not yet exist in the store.
What I'm currently doing is inserting a new entity with only a few fields set, but afterwards I find that the other attributes have been reset to nil on entities for which those attributes have already been set.
I am using a merge policy of NSMergeByPropertyObjectTrumpMergePolicy
which I believe would overwrite only the attributes I have set on my latest update.
I would like to avoid a complicated approach of first obtaining the entity, and then doing a field-by-field reset using old values.
core-data
core-data
edited Nov 22 at 1:23
asked Nov 22 at 1:14
andrewz
1,74532544
1,74532544
If you are always inserting a new entity, you are creating multiple entities. How do you make sure that you are updating the existing entity? Can you show your code?
– Mike Taverne
Nov 24 at 0:45
I have a constraint on an attribute in the entity that ensures uniqueness based on that attribute,
– andrewz
Nov 24 at 1:22
add a comment |
If you are always inserting a new entity, you are creating multiple entities. How do you make sure that you are updating the existing entity? Can you show your code?
– Mike Taverne
Nov 24 at 0:45
I have a constraint on an attribute in the entity that ensures uniqueness based on that attribute,
– andrewz
Nov 24 at 1:22
If you are always inserting a new entity, you are creating multiple entities. How do you make sure that you are updating the existing entity? Can you show your code?
– Mike Taverne
Nov 24 at 0:45
If you are always inserting a new entity, you are creating multiple entities. How do you make sure that you are updating the existing entity? Can you show your code?
– Mike Taverne
Nov 24 at 0:45
I have a constraint on an attribute in the entity that ensures uniqueness based on that attribute,
– andrewz
Nov 24 at 1:22
I have a constraint on an attribute in the entity that ensures uniqueness based on that attribute,
– andrewz
Nov 24 at 1:22
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422619%2fupdate-only-some-attributes-of-an-entity%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you are always inserting a new entity, you are creating multiple entities. How do you make sure that you are updating the existing entity? Can you show your code?
– Mike Taverne
Nov 24 at 0:45
I have a constraint on an attribute in the entity that ensures uniqueness based on that attribute,
– andrewz
Nov 24 at 1:22