nspredicate

Core Data, how can i find and delete managed objects effectively

北城余情 提交于 2019-12-12 00:28:28
问题 My app sends a get request to a server with a date (date of last update) to update its content (2 entities in core data, no relationships, all attributes are strings)... most of the time it only receives new content but sometimes it also receives the old content that needs to be updated instead of just inserted. 1 table is pretty straight forward I just get the ids (id from server not form core data) of the items that are going to be updated in an array and I make a fetch of those items and

Search only in array's that set ON in settings

最后都变了- 提交于 2019-12-12 00:09:56
问题 I need to search and filter only in array's that set ON in settings. Now I loop in dict for all array's: - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"Name CONTAINS[cd] %@ OR Address CONTAINS[cd] %@", searchText, searchText]; searchResults = [NSMutableArray array]; for (NSString *akey in dict) { NSLog(@"%@", akey); NSArray *array = [dict objectForKey:akey]; NSArray *matches = [array

NSPredicate with nested subqueries failing to compile(core data)

青春壹個敷衍的年華 提交于 2019-12-11 22:49:13
问题 My relevant part of the CoreDate DB Category<-->>Subcategory<-->>Gym<<-->>Membership I am trying to get all the Categories who have at lease one gym where the user has an active membership. I have an array with all the user's active membership uid's(every membership has a uid in the DB) I am trying the following query which fails to compile, I even decided it into substrings just to make sure no errors are made: NSString *shopsSubquery = [NSString stringWithFormat:@"(SUBQUERY($y.programs,$z,

NSPredicate for detecting Class of the property

江枫思渺然 提交于 2019-12-11 20:01:37
问题 I have events, each Event has to-one relationship with NSManagedObject Entertainment, and Entertainment has to-many relationship, and has NSSet of events @interface Event : NSManagedObject @property (nonatomic, retain) NSDate *creationDate; @property (nonatomic, retain) NSDate * date; @property (nonatomic, retain) NSString * objectId; @property (nonatomic, retain) NSString * price; @property (nonatomic, retain) Entertainment *entertainment; @property (nonatomic, retain) Place *place;

NSPredicate(s) for NSMetadataQuery to match kMDItemAccessedDates (array) containing a target date?

大城市里の小女人 提交于 2019-12-11 18:47:35
问题 UPDATE: I found an answer though there may still be a better way - see the answer added below. a spotlight importer imports metadata that is an array of dates in which an item was accessed. Looks like this: kMDItemAccessedDates = ( "2012-06-18 07:00:00 +0000", "2013-01-10 08:00:00 +0000", "2013-01-15 08:00:00 +0000" ) I'd like to query for any of these files that were accessed on a particular date the user enters but I'm not finding the right syntax to do this. Wondering if it's possible to

NSFetchResultsController + sectionNameKeyPath + section order

不羁的心 提交于 2019-12-11 17:35:59
问题 I have a one to many entity relationship between two entities: EntityP (Parent) <-->> EntityC (Child) Attributes and Relationships: EntityP.title EntityP.dateTimeStamp EntityP.PtoC (relationship) EntityC.title EntityC.dateTimeStamp EntityC.CtoP (relationship) // Can be used to get "one" EntityP record I use fetch results controller to show the results. Here's my implementation of the fetch results controller: #pragma mark - #pragma mark Fetched results controller - (NSFetchedResultsController

Filter Data in SwiftyJson

做~自己de王妃 提交于 2019-12-11 16:16:49
问题 I have one SwiftyJson object. I can not filter that array. I have tried this solution https://stackoverflow.com/a/37497170/4831567. But my json format is different that's why not working. [ { "name": "19860", "header": { "start_time": "1519270200", "end_time": "1519299000", "state": "lunch" }, "alerts": "1", "venue": { "location": "Delhi, India", "timezone": "+05:30" }, "srs_category": [ 0, 1 ] }, { "name": "19861", "header": { "start_time": "1519270200", "end_time": "1519299000", "state":

Using NSPredicate with transformable attribute in Core Data

你离开我真会死。 提交于 2019-12-11 14:45:43
问题 I have A class ( TestClass ) and it has two Properties ID : String and Code : Int . class TestClass : NSObject , NSCoding { @objc let ID : Int32 @objc let Code : String init(id : Int32, code : String) { self.ID = id self.Code = code } public func encode(with aCoder: NSCoder) { aCoder.encode(ID, forKey: "ID") aCoder.encode(Code, forKey: "Code") } required public convenience init?(coder aDecoder: NSCoder) { guard let id = aDecoder.decodeObject(forKey: "ID") as? Int32, let code = aDecoder

Action Extension activation rule predicate doesn't hide the action when multiple of the same type is selected

限于喜欢 提交于 2019-12-11 14:12:46
问题 Hello I am trying to make action extension to only work with a single GIF file. Here is my code (created using the snippet provided in Apple's documentation: SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.compuserve.gif" ).@count == $extensionItem.attachments.@count ).@count == 1 This extension is supposed to work inside Photos app and I have tried multiple scenarios: Single GIF file

How can I use predicateWithFormat for query a NSString is contained in an NSSet

拥有回忆 提交于 2019-12-11 14:11:36
问题 Using StackMob as backend. I have an Event entity which has a relationship called user users (type NSSet ). Right now I want to get all the events that some user's username is @"someuser" . My code like this: [self.client getLoggedInUserOnSuccess:^(NSDictionary *result) { NSString *currentlyLoggedInUser = [result valueForKey:@"username"]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *eventEntity = [NSEntityDescription entityForName:@"Event"