nspredicate

UISearchBar: FilterContentForSearchText not working on a UITableView (results not shown on table)

坚强是说给别人听的谎言 提交于 2019-12-25 06:22:27
问题 PROBLEM PARTLY SOLVED, SEE END OF POST: Showing search results on a UITableView not working. The table stays blank, doesn't show any results but the searching must work because when I search for something not in the table I get immediately "No Results" text shown on the table . Note: In IB I did connect the delegate of UISearchBar in Connection Inspector with my Controller . Hope you can help. m: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return

Help w/ array of dictionaries in a tableview

十年热恋 提交于 2019-12-25 04:29:14
问题 This is kinda confusing so please bear with me. I have an array (listOfStates) of dictionaries. Where listOfStates has this structure: {stateName} - {stateCapital} {Alabama} - {Montgomery} {Alaska} - {Juneau} {Arizona} - {Phoenix} ... {West Virginia} - {Charleston} {Wisconsin} - {Madison} {Wyoming} - {Cheyenne} This is the code used to obtain the 1st letter of each US State(stateName) in order to group them together alphabetically: listOfStates = [[NSArray alloc] init]; stateIndex = [

NSPredicate execureFetchRequest not working - possibly due to spaces in string

那年仲夏 提交于 2019-12-25 03:47:11
问题 I am trying to search in CoreData for an object that matches both a recordId and a string name, but it doesn't always find the object. For example, I an searching for an object with id 1000 and name "The Brown Family" (note the 2 spaces between "The" and "Brown"). If I use: NSPredicate *pred = [NSPredicate predicateWithFormat:@"(recordId == %@") AND (name like[cd] %@)", recordId, name]; with recordId=1000 and name="The Brown Family", the fetch request returns nil. If I use: NSPredicate *pred

Core data fetch predicate for NSDate

孤街醉人 提交于 2019-12-25 03:17:09
问题 I have entity with two NSDate properties: @property NSDate *startTime; @property NSDate *endTime; I use it for creating the point events and the duration events. So, for the point events endTime can be equal to nil. And i want to fetch all entities with restriction: startTime >= minDate && endTime <= maxDate But NSPredicate like: NSDate *startTime = [[NSUserDefaults standardUserDefaults] objectForKey:@"firstBound"]; NSDate *endTime = [[NSUserDefaults standardUserDefaults] objectForKey:@

Search bar with NSPredicate doesn't work

拟墨画扇 提交于 2019-12-25 02:29:50
问题 I've made a view for editing friend, with a searchbar. My adding/deleting friends is working fine, but I've a problem with my adding/deleting friends WITH SEARCHBAR... My searchbar finds well the email I'm tapping, but the order change : if I find 2 email with my searchbar, the 2 email will are the 2 first email in my property "Allfriend", and not the email I found with searchbar... Is there any code to complete in didSelectRowAtIndexPath after NSLog ? I let you see my code, tell me if you

Own function (round for NSString) in NSPredicate

大憨熊 提交于 2019-12-25 02:20:00
问题 I got problem with NSPredicate. I got predicate: NSPredicate* pr = [NSPredicate predicateWithFormat:@"FUNCTION('12.12345','round',3) = 12.123"]; and defined extension for NSString: -(double) round:(NSNumber*) precision; When I call manually: NSLog(@"%f",[s round:3]) where s is NSString, it's working prefectly, but used in NSPredicate rise: NSInvalidArgumentException: rease -[NSCFString round]: unrecognized selector sent to instance. I use solution used on page: http://funwithobjc.tumblr.com

NSPredicate without consider time component

末鹿安然 提交于 2019-12-25 01:49:53
问题 From my table I want select all rows of a particular date without considering the time component of NSDate.Please any one suggest a NSPredicate to achieve this ? 回答1: NSDate describes an absolute point in time and does not have "day" or "time" components. The same is true for a Core Data "Date" attribute, which is stored as the number of seconds since 1 January 2001, GMT in the database. What you probably want is to fetch all objects where some "Date" attribute falls into the interval given

Complex predicate with to-many relationship not working correctly

一曲冷凌霜 提交于 2019-12-25 01:20:52
问题 I have an app where i can search for a room to book it. In my first view I can select a city and the street. In the second view I can select some attributes (like wlan, tv...) In the 3rd view are the rooms that are available to the selection. When I don't select an attribute, it should show me all the rooms that are available for the selected street/city. Here is my predicate so far: NSPredicate *predicate = [NSPredicate predicateWithFormat: @"((raumattribute.schalter CONTAINS YES) AND\

Filter NSFileManger contents for a list of file 'patterns' using NSPredicate

一世执手 提交于 2019-12-24 21:28:29
问题 I've an array of strings to be used as a 'filter': @[@"*.png", @".DS_Store", @"Foobar", @".jpg"] How do I use above pattern to filter out all the contents of a folder using NSPredicate? This is what I've got so far: NSArray *contents = [fileManager contentsOfDirectoryAtPath:fullPath error:NULL]; NSArray *filter = @[@"*.png", @".DS_Store", @"Foobar", @".jpg"]; NSArray *contents = [contents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"((pathExtension IN[cd] %@) OR

Predicate search in core data causes SIGABRT on second time through. NSBetweenPredicateOperatorType

回眸只為那壹抹淺笑 提交于 2019-12-24 09:06:13
问题 I am seeing a really strange behavior in core data. I am doing a search for locations in core data (data store type is SQLite). The query is to look for location objects within a specific area. I am implementing the search as a between predicate. NSExpression *lhs = [NSExpression expressionForKeyPath:keyPath]; NSExpression *rhs = [NSExpression expressionForVariable:@"MIN_MAX"]; NSPredicate *predicateTemplate = [NSComparisonPredicate predicateWithLeftExpression:lhs rightExpression:rhs modifier