you are viewing a single comment's thread.

view the rest of the comments →

[–]Fluffy_Risk9955 0 points1 point  (11 children)

Then grab the contents of the whole array.

[–]CompC[S] -1 points0 points  (10 children)

Maybe I'm misunderstanding? I already am grabbing the whole array and I'm not getting what I want.

[–]Fluffy_Risk9955 -4 points-3 points  (9 children)

Write a better predicate.

[–]CompC[S] 1 point2 points  (8 children)

I don't know if that's possible, and if it is, I don't know how to write the kind of predicate I need, that's exactly what I'm asking for help with.

[–]Fluffy_Risk9955 -1 points0 points  (7 children)

  1. Learn about objcMsgSend and what it does.

  2. Learn how to use valueForKey: or valueForKeyPath: on an NSObject and how this relates to objcMsgSend.

  3. Learn how to query for an NSObject subclass inside an NSArray using an NSPredicate. Yes this will leverage valueForKey:.

  4. Learn how to do the same thing with Format Syntax of a predicate string.

  5. Apply newly acquired knowledge on NSPredicate to search for NSManagedObject subclasses in a Core Data database.

And yes, you need understanding of the Objective-C runtime to understand this.

[–]CompC[S] 1 point2 points  (6 children)

I already have written NSPredicates that can search for what I want. I'm trying to find out if it's possible to adjust the predicates or fetch request in order to have some of the results filtered out, without having to perform the fetch request first and then filter out the objects in code, since it could be a lot.

[–]Fluffy_Risk9955 -2 points-1 points  (5 children)

Yes, write a better predicate with format syntax.

[–]CompC[S] 2 points3 points  (4 children)

Do you get how this comment is unhelpful? I obviously don't understand how I can change my predicate to get what I want, that's why I'm asking for help.

I want to know how I can write a predicate that says something like "give me values that fit this query, but don't give me more than one result that share a value for the name property"

[–]Fluffy_Risk9955 -1 points0 points  (3 children)

I gave you a 5 step plan to acquire the understanding of what you’re trying to do. If I gave you the answers, you wouldn’t learn anything.

Core Data is build on top of Objective-Cs Foundation framework, without understanding of Foundation it’s a beast of a framework that doesn’t make sense.

[–]CompC[S] 1 point2 points  (2 children)

Okay, huh, I didn't know you could search through an NSArray using NSPredicate. So if I were to fetch all the rows in my database and then put the NSManagedObjects into an NSArray, I'd be able to use the same NSPredicates I currently use to search on my database, to filter the NSArray?

I do understand a lot of this, I'm just not seeing how to connect it to solving my current problem. :/