nspredicate

Is it possible use nested SUBQUERY in NSPredicate?

你离开我真会死。 提交于 2019-12-10 13:15:15
问题 As you can see I have two one-many relationships. Is it possible to write such a nested SUBQUERY where I want to select all A, where any of the belonging C-s under any of belonging B to A satisfy a certain condition? 回答1: You can nest SUBQUERY in a predicate. But it seems that a single SUBQUERY is sufficient here (if ds is a to-one relationship from C to D ), for example [NSPredicate predicateWithFormat:@"SUBQUERY(bs, $x, ANY $x.cs.ds.name = %@).@count > 0", name]; 来源: https://stackoverflow

NSMetadataQuery does not find NSFileWrapper folder bundles, only files (but they're there)

时光怂恿深爱的人放手 提交于 2019-12-10 11:33:02
问题 I have a strange problem which I can't seem to solve on my own. Any help or thought is appreciated. The problem: NSMetadataQuery finds normal files (like test.txt) but no filewrapper bundle (myWrapperDocument.pro) However, NSFileManager finds all files in my ubiquity container - so the files are there, but NSMetadataQuery doesn't find them! The facts: UIDocument based app using NSFileWrappers Shared Ubiquity Container (for iOS and Desktop app) Works perfect on Mac OS Works perfect on my iPad

NSPredicate and arrays

安稳与你 提交于 2019-12-10 11:27:55
问题 I've got a short question. I have an NSArray filled with Cars (which inherits from NSObject). Car has the @property NSString *engine (also regarded @synthesize ) Now I want to filter the array using NSPredicate : predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"(engine like %@)", searchText]]; newArray = [ArrayWithCars filteredArrayUsingPredicate:predicate]; This throws an valueForUndefinedKey error. Is the predicateWithFormat correct? Thanks for your responses. 回答1:

Filtering with NSPredicate, for array count of Array inside dictionary inside array

二次信任 提交于 2019-12-10 06:18:26
问题 I have Array of format as below [ { "xyz" : [Array with different values]; ... many more keys }, { .. same as above dictionary } ... many more dictionaries ] Here see, i have Main Array of dictionaries, where each dictionary have different keys, in which there is "xyz" key, whose value is again an Array. Now i want those dictionaries for which, xyz's array must have count>2. Now i have tried with following predicate: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"xyz.count>2"];

NSPredicate that filters out subclass results

柔情痞子 提交于 2019-12-10 04:46:54
问题 I have two classes, Company and MyCompany. MyCompany is a subclass of Company, and Company is a subclass of NSManagedObject. I am trying to write a predicate for an NSFetchRequest that will return results of the class Company, but filter out MyCompany objects. I have tried the following (suggested from here https://stackoverflow.com/a/8065935/472344): NSPredicate *predicate = [NSPredicate predicateWithFormat:@"class != %@",NSStringFromClass([myCompany class])]; But I get an error: 'keypath

Predicate to filter array of strings in SWIFT throws error saying NSCFString is not key-value coding

独自空忆成欢 提交于 2019-12-10 04:24:37
问题 Below is my code snippet //Search Bar Delegate func searchBar(searchBar: UISearchBar, textDidChange searchText: String) { println(searchText) var predicate:NSPredicate=NSPredicate(format: "SELF CONTAINS[c] \(searchText)")! self.listItemToBeDisplayed=listItem.filteredArrayUsingPredicate(predicate) (self.view.viewWithTag(1) as UITableView).reloadData() } Error I got: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0x17405ef90> valueForUndefinedKey:

NSFetchedResultsController and constructing NSFetchRequests

时间秒杀一切 提交于 2019-12-09 22:00:50
问题 I have setup Core Data for an iPhone app without an instance of NSFetchedResultsController. To do this, I created a created a model class to encapsulate all core data requests and constructing of NSFetchRequests/NSPredicates. This kept all Core Data specific code out of my UITableViewController. Now I want to add NSFetchedResultsController to make populating a sectioned UITableView easier. My issue is this: In all examples I have seen the instance NSFetchedResultsController is an ivar of the

Using NSPredicate in 2D Arrays

人走茶凉 提交于 2019-12-09 13:51:26
问题 This question is based off of the same app/source from my previous question which can be found here: How to manage memory using classes in Objective-C? I have a nested array which looks something like this when printed out (I only copied and pasted a brief part of it). ( ( <Term: 0x4256420>, <Term: 0x420fa40>, <Term: 0x4257bd0>, <Term: 0x4257cf0>, <Term: 0x4257d90>, <Term: 0x4257e30> ), ( <Term: 0x4257e50>, <Term: 0x4257f90>, <Term: 0x4257fb0>, <Term: 0x42580e0>, <Term: 0x4258170>, <Term:

avoid duplicate results on Core Data fetch

落爺英雄遲暮 提交于 2019-12-09 13:51:07
问题 I have a subclass of the CoreDataTableViewController (subclass of UITAbleViewController dome by the people on Stanford done to link CoreData and TableViews). On this Class, I want to perform a fecth, sorting by an attribute called "definition" and the code which executes it is the following: - (void)setupFetchedResultsController{ NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:self.entity]; request.propertiesToFetch=[NSArray arrayWithObject:@"definition"]; request

NSPredicate that ignores whitespaces

北慕城南 提交于 2019-12-09 12:35:02
问题 I need to use NSPredicate to match two strings, case-insensitive, diacritic insensitive, and whitespace-insensitive . The predicate would look something like this: [NSPredicate predicateWithFormat:@"Key ==[cdw] %@", userInputKey]; The 'w' modifier is an invented one to express what I'd like to use. I can't just trim the userInputKey because the data-source "Key" values might have whitespaces in them too (they need those whitespaces, I can't just trim them beforehand). For example, given a