Can I apply multiple predicates to an NSFetchRequest? Would it be better to manually parse my results?

Yes it’s possible. You’re looking for compound predicates and here’s an example with AND predicates: NSPredicate *compoundPredicate = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray of Predicates]]; You can also use notPredicateWithSubpredicates and orPredicateWithSubpredicates depending on your needs. Link to documentation https://developer.apple.com/documentation/foundation/nscompoundpredicate

Core data, how to get NSManagedObject’s ObjectId when NSFetchRequest returns NSDictionaryResultType?

Yes you can, using the very nifty but badly-documented NSExpressionDescription class. You need to add a properly-configured NSExpressionDescription object to the array of NSPropertyDescription objects you set via setPropertiesToFetch: for your NSFetchRequest. For example: NSExpressionDescription* objectIdDesc = [[NSExpressionDescription new] autorelease]; objectIdDesc.name = @”objectID”; objectIdDesc.expression = [NSExpression expressionForEvaluatedObject]; objectIdDesc.expressionResultType = NSObjectIDAttributeType; myFetchRequest.propertiesToFetch = [NSArray arrayWithObjects:objectIdDesc, anotherPropertyDesc, … Read more

SwiftUI View and @FetchRequest predicate with variable that can change

had the same problem, and a comment of Brad Dillon showed the solution: var predicate:String var wordsRequest : FetchRequest<Word> var words : FetchedResults<Word>{wordsRequest.wrappedValue} init(predicate:String){ self.predicate = predicate self.wordsRequest = FetchRequest(entity: Word.entity(), sortDescriptors: [], predicate: NSPredicate(format: “%K == %@”, #keyPath(Word.character),predicate)) } in this example, you can modify the predicate in the initializer.

CoreData get distinct values of Attribute

You should use the backing store to help you get distinct records. If you want to get an array with just John, Betty, Edward here’s how you do it: NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@”MyEntity”]; NSEntityDescription *entity = [NSEntityDescription entityForName:@”MyEntity” inManagedObjectContext:self.managedObjectContext]; // Required! Unless you set the resultType to NSDictionaryResultType, distinct can’t work. // All objects … Read more

How to get Core Data object from specific Object ID?

You want: -(NSManagedObject *)existingObjectWithID:(NSManagedObjectID *)objectID error:(NSError **)error Fetches the object from the store that has that ID, or nil if it doesn’t exist. (Be aware: there are two methods on NSManagedObjectContext with similar-seeming names that tripped me up. To help keep them straight, here’s what the other two do: -(NSManagedObject *)objectWithID:(NSManagedObjectID *)objectID …will create a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)