Swift Core Data NSPredicate static string issueCore Data Predicate not workingCore Data, NSPredicate and to-many keyNSPredicate - Unable to parse the format stringHow to escape a trailing backslash in an NSPredicate format stringCore Data NSPredicate with a fetch property as criteria?Get Entities that fulfill predicate even some have null object for parentCore Data - Swift - Catch “keypath not found in entity” errorNSPredicate 'IN' operator formatting issue in swift. Unable to parse the format stringCore data use aggregate function in filterSwift Core Data Predicate IN ClauseNSPredicate to filter Core Data Relationship NSSet by attribute
Many many thanks
Can someone identify this unusual plane at airport?
Why does the `ls` command sort files like this?
Did anybody find out it was Anakin who blew up the command center?
Is there any problem with a full installation on a USB drive?
No hyphenation on "section", "Table", etc. with Cleveref package
Time difference between banns and marriage
Why does this London Underground poster from 1924 have a Star of David atop a Christmas tree?
Units in general relativity
Is a memoized pure function itself considered pure?
Group riding etiquette
Is the internet in Madagascar faster than in UK?
Fantasy Macro Economics: What would Merfolk Trade?
How to pass 2>/dev/null as a variable?
Why does a sticker slowly peel off, but if it is pulled quickly it tears?
How to force GCC to assume that a floating-point expression is non-negative?
Book featuring a child learning from a crowdsourced AI book
How do we improve collaboration with problematic tester team?
Why this brute force attack doesn't reduce all cryptographic hash functions' security bits against collision attacks to N/3?
Can an object tethered to a spaceship be pulled out of event horizon?
How could a self contained organic body propel itself in space
Defending Castle from Zombies
Can I take a boxed bicycle on a German train?
Federal Pacific 200a main panel problem with oversized 100a 2pole breaker
Swift Core Data NSPredicate static string issue
Core Data Predicate not workingCore Data, NSPredicate and to-many keyNSPredicate - Unable to parse the format stringHow to escape a trailing backslash in an NSPredicate format stringCore Data NSPredicate with a fetch property as criteria?Get Entities that fulfill predicate even some have null object for parentCore Data - Swift - Catch “keypath not found in entity” errorNSPredicate 'IN' operator formatting issue in swift. Unable to parse the format stringCore data use aggregate function in filterSwift Core Data Predicate IN ClauseNSPredicate to filter Core Data Relationship NSSet by attribute
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I would like to make predicate more flexible for changes. I have lot of such strings in the sources code:
let predicate = NSPredicate(format: "bodyPart.name = %@", name)
let filteredExercises = ExerciseEntity.mr_findAll(with: predicate)
but as you see if I will change BodyPart name to MuscleGroup for example someday it will cause issue like:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath bodyPart.name not found in entity <NSSQLEntity ExerciseEntity id=5>'
I am searching for the solution with a key paths like
let predicate = NSPredicate(format: "%@ = %@", BodyPart.name, name)
ios swift core-data nspredicate
add a comment |
I would like to make predicate more flexible for changes. I have lot of such strings in the sources code:
let predicate = NSPredicate(format: "bodyPart.name = %@", name)
let filteredExercises = ExerciseEntity.mr_findAll(with: predicate)
but as you see if I will change BodyPart name to MuscleGroup for example someday it will cause issue like:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath bodyPart.name not found in entity <NSSQLEntity ExerciseEntity id=5>'
I am searching for the solution with a key paths like
let predicate = NSPredicate(format: "%@ = %@", BodyPart.name, name)
ios swift core-data nspredicate
Compare stackoverflow.com/a/41638253/1187415.
– Martin R
Mar 27 at 20:55
add a comment |
I would like to make predicate more flexible for changes. I have lot of such strings in the sources code:
let predicate = NSPredicate(format: "bodyPart.name = %@", name)
let filteredExercises = ExerciseEntity.mr_findAll(with: predicate)
but as you see if I will change BodyPart name to MuscleGroup for example someday it will cause issue like:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath bodyPart.name not found in entity <NSSQLEntity ExerciseEntity id=5>'
I am searching for the solution with a key paths like
let predicate = NSPredicate(format: "%@ = %@", BodyPart.name, name)
ios swift core-data nspredicate
I would like to make predicate more flexible for changes. I have lot of such strings in the sources code:
let predicate = NSPredicate(format: "bodyPart.name = %@", name)
let filteredExercises = ExerciseEntity.mr_findAll(with: predicate)
but as you see if I will change BodyPart name to MuscleGroup for example someday it will cause issue like:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath bodyPart.name not found in entity <NSSQLEntity ExerciseEntity id=5>'
I am searching for the solution with a key paths like
let predicate = NSPredicate(format: "%@ = %@", BodyPart.name, name)
ios swift core-data nspredicate
ios swift core-data nspredicate
asked Mar 27 at 20:38
Matrosov AlexanderMatrosov Alexander
9,34939 gold badges120 silver badges234 bronze badges
9,34939 gold badges120 silver badges234 bronze badges
Compare stackoverflow.com/a/41638253/1187415.
– Martin R
Mar 27 at 20:55
add a comment |
Compare stackoverflow.com/a/41638253/1187415.
– Martin R
Mar 27 at 20:55
Compare stackoverflow.com/a/41638253/1187415.
– Martin R
Mar 27 at 20:55
Compare stackoverflow.com/a/41638253/1187415.
– Martin R
Mar 27 at 20:55
add a comment |
1 Answer
1
active
oldest
votes
Use %K to substitute the key path
let predicate = NSPredicate(format: "%K = %@", #keyPath(BodyPart.name), name)
It should be#keyPath(BodyPart.name)
, compare stackoverflow.com/a/41638253/1187415
– Martin R
Mar 27 at 20:53
Thanks for the reminder about #keyPath
– Joakim Danielson
Mar 27 at 20:55
thanks for comments
– Matrosov Alexander
Mar 27 at 21:18
it will just return "name == some name" but I need "bodyPart.name", for sure I can combine to strings I guess) thanks good solution!
– Matrosov Alexander
Mar 27 at 21:20
1
@MatrosovAlexander, shouldn't it be like Martin R suggests above#keyPath(ExerciseEntity.muscle.name)
?
– Joakim Danielson
Mar 27 at 21:28
|
show 4 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f55386045%2fswift-core-data-nspredicate-static-string-issue%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use %K to substitute the key path
let predicate = NSPredicate(format: "%K = %@", #keyPath(BodyPart.name), name)
It should be#keyPath(BodyPart.name)
, compare stackoverflow.com/a/41638253/1187415
– Martin R
Mar 27 at 20:53
Thanks for the reminder about #keyPath
– Joakim Danielson
Mar 27 at 20:55
thanks for comments
– Matrosov Alexander
Mar 27 at 21:18
it will just return "name == some name" but I need "bodyPart.name", for sure I can combine to strings I guess) thanks good solution!
– Matrosov Alexander
Mar 27 at 21:20
1
@MatrosovAlexander, shouldn't it be like Martin R suggests above#keyPath(ExerciseEntity.muscle.name)
?
– Joakim Danielson
Mar 27 at 21:28
|
show 4 more comments
Use %K to substitute the key path
let predicate = NSPredicate(format: "%K = %@", #keyPath(BodyPart.name), name)
It should be#keyPath(BodyPart.name)
, compare stackoverflow.com/a/41638253/1187415
– Martin R
Mar 27 at 20:53
Thanks for the reminder about #keyPath
– Joakim Danielson
Mar 27 at 20:55
thanks for comments
– Matrosov Alexander
Mar 27 at 21:18
it will just return "name == some name" but I need "bodyPart.name", for sure I can combine to strings I guess) thanks good solution!
– Matrosov Alexander
Mar 27 at 21:20
1
@MatrosovAlexander, shouldn't it be like Martin R suggests above#keyPath(ExerciseEntity.muscle.name)
?
– Joakim Danielson
Mar 27 at 21:28
|
show 4 more comments
Use %K to substitute the key path
let predicate = NSPredicate(format: "%K = %@", #keyPath(BodyPart.name), name)
Use %K to substitute the key path
let predicate = NSPredicate(format: "%K = %@", #keyPath(BodyPart.name), name)
edited Mar 27 at 20:55
answered Mar 27 at 20:45
Joakim DanielsonJoakim Danielson
14.7k3 gold badges8 silver badges27 bronze badges
14.7k3 gold badges8 silver badges27 bronze badges
It should be#keyPath(BodyPart.name)
, compare stackoverflow.com/a/41638253/1187415
– Martin R
Mar 27 at 20:53
Thanks for the reminder about #keyPath
– Joakim Danielson
Mar 27 at 20:55
thanks for comments
– Matrosov Alexander
Mar 27 at 21:18
it will just return "name == some name" but I need "bodyPart.name", for sure I can combine to strings I guess) thanks good solution!
– Matrosov Alexander
Mar 27 at 21:20
1
@MatrosovAlexander, shouldn't it be like Martin R suggests above#keyPath(ExerciseEntity.muscle.name)
?
– Joakim Danielson
Mar 27 at 21:28
|
show 4 more comments
It should be#keyPath(BodyPart.name)
, compare stackoverflow.com/a/41638253/1187415
– Martin R
Mar 27 at 20:53
Thanks for the reminder about #keyPath
– Joakim Danielson
Mar 27 at 20:55
thanks for comments
– Matrosov Alexander
Mar 27 at 21:18
it will just return "name == some name" but I need "bodyPart.name", for sure I can combine to strings I guess) thanks good solution!
– Matrosov Alexander
Mar 27 at 21:20
1
@MatrosovAlexander, shouldn't it be like Martin R suggests above#keyPath(ExerciseEntity.muscle.name)
?
– Joakim Danielson
Mar 27 at 21:28
It should be
#keyPath(BodyPart.name)
, compare stackoverflow.com/a/41638253/1187415– Martin R
Mar 27 at 20:53
It should be
#keyPath(BodyPart.name)
, compare stackoverflow.com/a/41638253/1187415– Martin R
Mar 27 at 20:53
Thanks for the reminder about #keyPath
– Joakim Danielson
Mar 27 at 20:55
Thanks for the reminder about #keyPath
– Joakim Danielson
Mar 27 at 20:55
thanks for comments
– Matrosov Alexander
Mar 27 at 21:18
thanks for comments
– Matrosov Alexander
Mar 27 at 21:18
it will just return "name == some name" but I need "bodyPart.name", for sure I can combine to strings I guess) thanks good solution!
– Matrosov Alexander
Mar 27 at 21:20
it will just return "name == some name" but I need "bodyPart.name", for sure I can combine to strings I guess) thanks good solution!
– Matrosov Alexander
Mar 27 at 21:20
1
1
@MatrosovAlexander, shouldn't it be like Martin R suggests above
#keyPath(ExerciseEntity.muscle.name)
?– Joakim Danielson
Mar 27 at 21:28
@MatrosovAlexander, shouldn't it be like Martin R suggests above
#keyPath(ExerciseEntity.muscle.name)
?– Joakim Danielson
Mar 27 at 21:28
|
show 4 more comments
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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.
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%2f55386045%2fswift-core-data-nspredicate-static-string-issue%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
Compare stackoverflow.com/a/41638253/1187415.
– Martin R
Mar 27 at 20:55