core-data

Is there a way to figure out what thread an NSManagedObjectContext is on?

只谈情不闲聊 提交于 2020-01-24 10:35:07
问题 My understanding of threads with respect to an NSManagedObjectContext is that it can only execute core data fetch requests, deletes, etc., on the thread from which it was created. Is there any way to check to see what thread an NSManagedObjectContext was created on, or if at a particular point of execution the current thread is that of a particular NSManagedObjectContext ? Thanks! 回答1: My understanding of threads with respect to an NSManagedObjectContext is that it can only execute core data

Efficient way to update table section headers using Core Data entities?

天大地大妈咪最大 提交于 2020-01-24 09:44:05
问题 Im using a NSFetchedResultsController for my UITableView which displays a bunch of events im storing in core data. What i am trying to do is group the table by relative date (ie Today, Tomorrow, This Week, etc..). Each event has a start date and i tried creating a transient property in the event entity called sectionIdentifier which converts the date into a relative date as mentioned above like so: - (NSString*)sectionIdentifier { [self willAccessValueForKey:@"sectionIdentifier"]; NSString

Core Data reverts to previous state without apparent reason

孤者浪人 提交于 2020-01-24 03:27:24
问题 A few customers of a Core Data based iOS application report that they occassionally lose data. The reports are very odd, which is the reason I'd like to ask for your take on this. The customers report that when they reopen the application after some time (minutes, hours, or next day), some of their data is lost as if the underlying database reverted to a previous state . I have been working with Core Data for several years and have never run in an issue like this before. The application is

reloading tableview as per notification after deletion of object in coredata shows weird result

人走茶凉 提交于 2020-01-24 01:05:09
问题 I am new to this coredata. Just to be familiar with relationship i created two entities CategoryList (consists of attribute 'categories') and ExpenseList(consists of attribute 'amountspent') which has a to many relationship. Relationship from 'CategoryList' To 'ExpenseList' is 'expenselist'. The 1st tableview shows the total expense in each categories like food -150 transportation -100 mobile -100 shopping -500 and the second tableview shows individual expenses like food -100 food -50

How to create unique identifier for an entity in iphone core data

99封情书 提交于 2020-01-24 00:45:10
问题 I am new to core data and iphone programming so dont mind my silly qn. I couldn't figure out how to mark a attribute as a primary key in the xcdatamodel file or may be outside. I looked around and found some people saying that it is not possible. I am getting identifier for every object that i am getting, i would need to store that object through core data and i might need to use that identifier in my web service to retrieve additional data. How do i keep the primary key of an entity equal to

CoreData performFetch in viewDidLoad not working

和自甴很熟 提交于 2020-01-23 11:08:06
问题 When my main view controller is loaded and it calls viewDidLoad I am performing a fetch request and retiring an array or my core data objects: + (NSArray *)getData { // Fetch Data NSError *error = nil; if (![[[AppDelegate instance] fetchedResultsController] performFetch:&error]) { // Update to handle the error appropriately. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } NSArray *items = [[AppDelegate instance].fetchedResultsController fetchedObjects]; return items; }/

CoreData performFetch in viewDidLoad not working

荒凉一梦 提交于 2020-01-23 11:05:43
问题 When my main view controller is loaded and it calls viewDidLoad I am performing a fetch request and retiring an array or my core data objects: + (NSArray *)getData { // Fetch Data NSError *error = nil; if (![[[AppDelegate instance] fetchedResultsController] performFetch:&error]) { // Update to handle the error appropriately. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } NSArray *items = [[AppDelegate instance].fetchedResultsController fetchedObjects]; return items; }/

Pre-populated database. Now I want to add more data without messing the pre-existing data

眉间皱痕 提交于 2020-01-23 10:45:10
问题 I have set up and app which has pre-populated data that copies the database to the project's store. Using the 'CoreDataBooks example' method: Any way to pre populate core data? For application upgrades, I want to add more data to the database but I don't want to change the existing database since new user data is stored there? What's the best way to do this? I'm thinking I would create a new versioned managed object model (I'm not sure if you can add a new MOM version if nothing in the schema

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

Storing custom objects with Core Data

南笙酒味 提交于 2020-01-23 03:58:06
问题 I'm trying to store a NSMutableArray consisting of VOs (NameVO) with Core Data but getting the following exception thrown: 'NSInvalidArgumentException', reason: '-[NameVO encodeWithCoder:]: unrecognized selector sent to instance 0x1096400a0' My NameVO is just a simple value object, extending NSObject and contains two fields, a string and a NSMutableArray that itself contains strings. It also contains a compare function. I'm trying to prepare this to be stored as a CD transformable attribute