nspredicate

core data how to filter (NSPredicate) including a relationship requirement and given the relationship object? [closed]

↘锁芯ラ 提交于 2019-12-01 05:12:30
How would I filter (construct an NSPredicate) for the following. Have a SCHOOL and PERSON entities One-to-many relationship, i.e. a PERSON has one SCHOOL, SCHOOL has many PERSONs Input to the filter method are (a) persons Name (e.g. all with a first name of "Tom") , and (b) the managed object of the School itself. for the purposes of this question assume School has no unique attributes So then my confusion/observations are: I already have the School managed object itself, however not sure how to use this when creating the predicate? But if I create the NSPredicate how do I create the

NSPredicateEditor & NSExpression - Can the display be different than the value for the predicate?

懵懂的女人 提交于 2019-12-01 04:58:26
I have a predicate editor, which the template was generate via the following: NSArray * test = [NSArray arrayWithObjects: [NSExpression expressionForKeyPath: @"Abc"], [NSExpression expressionForKeyPath: @"Def"], nil]; NSPredicateEditorRowTemplate * template = [[NSPredicateEditorRowTemplate alloc] initWithLeftExpressions: test rightExpressionAttributeType: NSStringAttributeType modifier: NSDirectPredicateModifier operators: [NSArray arrayWithObject: [NSNumber numberWithUnsignedInteger:NSContainsPredicateOperatorType]] options:(NSCaseInsensitivePredicateOption

NSMetadataQuery ignoring custom file package type

为君一笑 提交于 2019-12-01 03:29:19
问题 I'm using UIManagedDocument s to manage my files in iCloud. After setting up the NSMetadataQuery like so: iCloudQuery = [[NSMetadataQuery alloc] init]; [iCloudQuery setSearchScopes: [NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]]; [iCloudQuery setPredicate: [NSPredicate predicateWithFormat:@"%K like %@", NSMetadataItemFSNameKey, @"DocumentMetadata.plist"]]; I'm encountering a curious problem - when my documents are named without a file extension (for example @"NewDocument2"

core data how to filter (NSPredicate) including a relationship requirement and given the relationship object? [closed]

。_饼干妹妹 提交于 2019-12-01 02:44:02
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . How would I filter (construct an NSPredicate) for the following. Have a SCHOOL and PERSON entities One-to-many relationship, i.e. a PERSON has one SCHOOL, SCHOOL has many PERSONs Input to the filter method are (a) persons Name (e.g. all with a first name of "Tom") , and (b) the

NSPredicateEditor & NSExpression - Can the display be different than the value for the predicate?

懵懂的女人 提交于 2019-12-01 02:20:49
问题 I have a predicate editor, which the template was generate via the following: NSArray * test = [NSArray arrayWithObjects: [NSExpression expressionForKeyPath: @"Abc"], [NSExpression expressionForKeyPath: @"Def"], nil]; NSPredicateEditorRowTemplate * template = [[NSPredicateEditorRowTemplate alloc] initWithLeftExpressions: test rightExpressionAttributeType: NSStringAttributeType modifier: NSDirectPredicateModifier operators: [NSArray arrayWithObject: [NSNumber numberWithUnsignedInteger

Fetched Properties - Predicate

北慕城南 提交于 2019-12-01 01:35:37
I have a question about using fetched properties inside a NSPredicate (see below 'My question'). It's not about the predicate to get the fetched property. For clarification and for others, which may also face this problem I tried to make a small sample project. SAMPLE PROJECT The need to use Fetched Properties came, because my app was rejected because of violating the iOS Data Storage Guidelines. In QA1719 they write: Apps should avoid mingling app data and user data in the same file. I think this may be necessary for easier ICloud sync and may also help in migration. So, how to do this? I had

Find values in NSArray having NSArray with NSString using NSPredicate iOS

霸气de小男生 提交于 2019-12-01 00:41:12
With NSArray only i can find values as: NSArray *arr = [NSArray arrayWithObjects:@"299-1-1", @"299-2-1", @"299-3-1", @"399-1-1", @"399-2-1", @"399-3-1", @"499-1-1", @"499-2-1", @"499-3-1", nil]; NSString *search = @"299"; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS %@",[NSString stringWithFormat:@"%@", search]]; NSArray *array = [arr filteredArrayUsingPredicate: predicate]; NSLog(@"result: %@", array); Found Result as expected : result: ( "299-1-1", "299-2-1", "299-3-1" ) But for NSArray having NSArray with NSString NSArray *arr = [NSArray arrayWithObjects:

NSPredicate, get results with a subset of one-to-many relationship

孤街浪徒 提交于 2019-12-01 00:35:21
I'mm working around with Core Data and NSFetchedResultsController . My Data Model looks like this: Product with one-to-many relationship called dataLines . The dataLine entity has a property name theWeek . I want to fetch all Product where dataLines.theWeek == someValue . This is easily done with a subquery. But this returns all dataLines. Is it possible to create a NSPredicate that returns the Product and a subset if dataLines only with the dataLines == someValue ? What you want to achieve could be reached in two ways: using a SUBQUERY [NSPredicate predicateWithFormat:@"SUBQUERY(dataLines, $x

Swift Core Data Predicate IN Clause

此生再无相见时 提交于 2019-11-30 21:58:37
I'm attempting to use an IN clause with an NSPredicate. I'm getting the following error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xa000000000000611' Here's the code: let fetchRequest: NSFetchRequest<Employee> = NSFetchRequest(entityName: "Employee") fetchRequest.sortDescriptors = [ NSSortDescriptor.init(key: "lastName", ascending: true) ] fetchRequest.predicate = NSPredicate(format: "ANY id IN %@", argumentArray: recentEmployeeIds)

What is wrong in my nested SUBQUERY predicate?

时光怂恿深爱的人放手 提交于 2019-11-30 20:39:58
I have the data model you can see below, and a nested SUBQUERY predicate, but in somehow it just not works. Any idea how to correct it? I figured out, this here down is working finally: [NSPredicate predicateWithFormat:@"SUBQUERY(bs, $B, SUBQUERY($B.cs, $C, $C.ds.name != \"xxx\").@count > 0).@count > 0"]; Ok, so here is the working solution: [NSPredicate predicateWithFormat:@"SUBQUERY(bs, $B, SUBQUERY($B.cs, $C, $C.ds.name != \"xxx\").@count > 0).@count > 0"]; 来源: https://stackoverflow.com/questions/13242383/what-is-wrong-in-my-nested-subquery-predicate