nspredicate

NSPredicate on nested array with NSDictionary as object

假装没事ソ 提交于 2020-02-16 05:25:24
问题 i have a NSDictionary like: { "2017-05-02" = ( { "always_valid" = 0; date = "2017-05-02"; from = "12:00"; to = "13:00"; }, { "always_valid" = 0; date = "2017-05-02"; from = "12:00"; to = "12:00"; }, { "always_valid" = 0; date = "2017-05-02"; from = "14:00"; "hourly_rate" = 12; to = "15:00"; } ); "2017-05-03" = ( { "always_valid" = 0; date = "2017-05-03"; from = "12:00"; to = "13:00"; } ); "2017-05-18" = ( { "always_valid" = 1; date = "2017-05-18"; from = "12:00"; to = "12:00"; } ); } i'm

一个正则表达式测试(只可输入中文、字母和数字)

时间秒杀一切 提交于 2020-02-13 01:59:57
首先举一个例子: 匹配9-15个由字母/数字组成的字符串的正则表达式: NSString * regex = @"^[A-Za-z0-9]{9,15}$"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex]; BOOL isMatch = [pred evaluateWithObject:txtfldPhoneNumber.text]; 假如是在OC里用,一定要注意细节。 列出我在项目中用到的代码: NSString *regex = @"[a-zA-Z\u4e00-\u9fa5][a-zA-Z0-9\u4e00-\u9fa5]+"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex]; if(![pred evaluateWithObject: nickNameTextField.text]) { /* ////此动画为弹出buttonqww UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"昵称只能由中文、字母或数字组成" delegate:self

NSFetchedResultsController and getting the grouping right

廉价感情. 提交于 2020-01-25 22:52:49
问题 I have the following problem. I have a UITableview that is powered by an NSFetchedResultsController. It should display let's say a projects, folders and files. There is no bigger hierarchy than that. So a project has several folders and those have several files. Now my table view should display those files, grouped by folders. So i thought my fetch requests' predicate would simply be: [NSPredicate predicateWithFormat:@"folder.project = %@", self.project]; I would then use MagicalRecord to

Class is not key value coding-compliant for the key staticTexts

耗尽温柔 提交于 2020-01-24 18:00:18
问题 I have this error: XCTAssertTrue failed: throwing "[<XCElementSnapshot 0x7fea978b1a10> valueForUndefinedKey:]: this class is not key value coding-compliant for the key staticTexts." Here is the code: let predicate = NSPredicate(format: "(self.staticTexts[%@].exists == true) AND (self.staticTexts[%@].exists == true)", message, nameString) XCTAssert(app.collectionViews.childrenMatchingType(.Cell).elementMatchingPredicate(predicate).exists) Error is thrown on the second line. I have looked at

Core Data NSPredicate fetch on entity relationship using in clause

微笑、不失礼 提交于 2020-01-23 05:11:24
问题 I would like to be able to search the relationship of an entity using an IN clause. I have the following setup: I would like to send over an array of nicknames and find all Persons associated with those nicknames. //array of names to find let nameArray: [String] = ["Tom", "Tommy", "Thomas"] // find all Persons who have a nickname associated with that person let predicate = NSPredicate(format: "ANY Person.nickName in %@",nameArray) var fetch = NSFetchRequest(entityName: "Person") fetch

How to search an NSSet or NSArray for an object which has an specific value for an specific property?

血红的双手。 提交于 2020-01-18 21:32:28
问题 How to search an NSSet or NSArray for an object which has an specific value for an specific property? Example: I have an NSSet with 20 objects, and every object has an type property. I want to get the first object which has [theObject.type isEqualToString:@"standard"] . I remember that it was possible to use predicates somehow for this kind of stuff, right? 回答1: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"type == %@", @"standard"]; NSArray *filteredArray = [myArray

How do I do this NSPredicate code?

限于喜欢 提交于 2020-01-16 00:56:08
问题 I'm having trouble with NSPredicate. I have a core data object called Entry, which contains an NSDate called creationDate. I want to compare this to the variable I have called date. I'm using an NSDate category to pull out the individual year of both objects, and a core data category to perform a predicate on all Entry objects in my core data store. [Entry allForPredicate:[NSPredicate predicateWithFormat:@"creationDate.year == %i", date.year]]; I think this is wrong, as it's not giving me the

Not update Table after saving or updating Core data - Swift

风格不统一 提交于 2020-01-15 10:16:15
问题 I have bellow class for my CRUD in my project: class ProjectCoreDataStore: DegreesProtocol, DegreesStoreUtilityProtocol { // MARK: - Managed object contexts var mainManagedObjectContext: NSManagedObjectContext var privateManagedObjectContext: NSManagedObjectContext // MARK: - Object lifecycle init() { //let fileName: String = "PortalMDBApp.sqlite" let fileName: String = "MDB.sqlite" let fileManager:FileManager = FileManager.default let directory = fileManager.urls(for: .documentDirectory, in:

Not update Table after saving or updating Core data - Swift

送分小仙女□ 提交于 2020-01-15 10:16:08
问题 I have bellow class for my CRUD in my project: class ProjectCoreDataStore: DegreesProtocol, DegreesStoreUtilityProtocol { // MARK: - Managed object contexts var mainManagedObjectContext: NSManagedObjectContext var privateManagedObjectContext: NSManagedObjectContext // MARK: - Object lifecycle init() { //let fileName: String = "PortalMDBApp.sqlite" let fileName: String = "MDB.sqlite" let fileManager:FileManager = FileManager.default let directory = fileManager.urls(for: .documentDirectory, in:

Filter NSArray with NSDictionary (nested level of object) using NSPredicate ANY and IN?

北慕城南 提交于 2020-01-14 06:09:17
问题 I have one main array named originalListArray with multiple objects.Here is the example of object. Example.json I want to find that number of objects from the originalListArray , who have amenity_id matched with my filter data. I have do this, create one predicate usign ANY not self becuase NSArray with NSDictionary and in that Dictionary object may have NSArray data. This is working fine. NSPredicate *predicate=[NSPredicate predicateWithFormat:@"ANY amenities.amenity_id =='1')"]; This is not