nsfetchrequest

fetchRequestFromTemplateWithName variables

▼魔方 西西 提交于 2020-03-20 18:15:27
问题 I'm using Xcode 4.2.1 and trying to use a variable. I understand in xcode 4 you need to set the variable with $variable . I have in Xcode for my fetch request the variable as $currDate and my code as NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter setDateFormat:@"YYYYMMdd"]; NSDate *currDate = [NSDate date]; NSString *currDateString = [dateFormatter stringFromDate:currDate]; NSError *error; NSFetchRequest *fetchRequest = [[[DataManager sharedInstance]

fetchRequestFromTemplateWithName variables

为君一笑 提交于 2020-03-20 18:12:43
问题 I'm using Xcode 4.2.1 and trying to use a variable. I understand in xcode 4 you need to set the variable with $variable . I have in Xcode for my fetch request the variable as $currDate and my code as NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter setDateFormat:@"YYYYMMdd"]; NSDate *currDate = [NSDate date]; NSString *currDateString = [dateFormatter stringFromDate:currDate]; NSError *error; NSFetchRequest *fetchRequest = [[[DataManager sharedInstance]

fetchRequestFromTemplateWithName variables

╄→гoц情女王★ 提交于 2020-03-20 18:12:19
问题 I'm using Xcode 4.2.1 and trying to use a variable. I understand in xcode 4 you need to set the variable with $variable . I have in Xcode for my fetch request the variable as $currDate and my code as NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter setDateFormat:@"YYYYMMdd"]; NSDate *currDate = [NSDate date]; NSString *currDateString = [dateFormatter stringFromDate:currDate]; NSError *error; NSFetchRequest *fetchRequest = [[[DataManager sharedInstance]

coredata - fetch one attribute into an array

拟墨画扇 提交于 2020-01-29 04:40:17
问题 Aim: I would like to fetch the value of one attribute (from an entity) from the database (core data) into an array. Example Entity Name = Employees Attribute = employeeID I just want all the employeeIDs populated into an array / set. Question Given below is my implementation, I just feel it is kind of a round about way, I would like to know if there is a better way to do this. Code NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Employees"]; fetchRequest.resultType

CoreStore refetch predicate NSFetchRequest issue

邮差的信 提交于 2020-01-25 09:34:07
问题 if I got it clear I need to refetch monitor when I search something: I have this function to refetch with provided string func search(searchText: String) { self.monitor.refetch(.where(format: "%K CONTAINS[cd] %@", #keyPath(ListEntityType.name), searchText), OrderBy<ListEntityType>(.ascending("name"))) } but this code is not compilable, only this below: func search(searchText: String) { self.monitor.refetch(Where<ListEntityType>("name", isEqualTo: searchText), OrderBy<ListEntityType>(

Working with fetched request sort descriptors

北城余情 提交于 2020-01-24 12:33:30
问题 I have problem with my sort descriptor. I am fetching a ranking of a football club. This is how my webservice gives the data back. "ranking": [ { "type": "competitie", "position": "1", "name": "Club Brugge", "gamesPlayed": "10", "gamesWon": "6", "gamesTied": "4", "gamesLost": "0", "goalsPos": "25", "goalsNeg": "12", "goalsDiff": 13, "points": "22" } Here is my fetch request. - (void)getKlassement // attaches an NSFetchRequest to this UITableViewController { NSFetchRequest *request =

Working with fetched request sort descriptors

那年仲夏 提交于 2020-01-24 12:32:57
问题 I have problem with my sort descriptor. I am fetching a ranking of a football club. This is how my webservice gives the data back. "ranking": [ { "type": "competitie", "position": "1", "name": "Club Brugge", "gamesPlayed": "10", "gamesWon": "6", "gamesTied": "4", "gamesLost": "0", "goalsPos": "25", "goalsNeg": "12", "goalsDiff": 13, "points": "22" } Here is my fetch request. - (void)getKlassement // attaches an NSFetchRequest to this UITableViewController { NSFetchRequest *request =

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 fetch just object IDs but also include the row data in CoreData?

寵の児 提交于 2020-01-22 10:00:27
问题 In the CoreData Apple Docs on working in the background, I came across this bit of advice: For example, you can configure a fetch request to return just object IDs but also include the row data (and update the row cache) —this can be useful if you're just going to pass those object IDs from a background thread to another thread. I was wondering how you might implement this fetch request? Specifically how to update the row cache. I think this is how get just the IDs: NSFetchRequest* request =

How to group fetched result from Core Data, iOS dev

徘徊边缘 提交于 2020-01-15 23:03:23
问题 I have a core data with an Entity called "Expense", its like: Entity: "Expense" Attributes: "Date", "Category", "Amount".......... My question is that is it possible to fetch how many expenses by year or year-month? I know if the fetch is based on time period or category, I can use NSPredicate to filter the fetched result. But the "Date" attribute in my mind should be seperated by year and month, so I can group them as in SQL query. Is it possible to do that directly in fetch? Otherwise the