core-data

Prepopulated stored data in iOS4

浪尽此生 提交于 2020-01-06 08:32:08
问题 I work with iPhone iOS 4.3. In my project I need a read-only, repopulated table of data (say a table with 20 rows and 20 fields). This data has to be fetched by key on the row. What is better approach? CoreData Archives, SQLite, or other? And how can I prepare and store this table? Thank you. 回答1: I would use core data for that. Drawback: You have to write a program (Desktop or iOS) to populate the persistent store. How to use a pre-populated store, you should have a look into the Recipes

Deleting a cell in search bar table view causes delete to be executed twice

眉间皱痕 提交于 2020-01-06 08:31:29
问题 I have a table view backed up by core data with NSFetchedResultsController instance. This table has a search bar that displays filtered data. The search bar has a separate NSFetchedResultsController (FRC from now) instance. So far so good, the data is fetched and shown as expected in the table view and also shown correctly in the search bar's table view (when searching for data). My problem is that if I try to delete a cell in the search bar's table view then I get a coredata exception :

Deleting a cell in search bar table view causes delete to be executed twice

旧时模样 提交于 2020-01-06 08:31:06
问题 I have a table view backed up by core data with NSFetchedResultsController instance. This table has a search bar that displays filtered data. The search bar has a separate NSFetchedResultsController (FRC from now) instance. So far so good, the data is fetched and shown as expected in the table view and also shown correctly in the search bar's table view (when searching for data). My problem is that if I try to delete a cell in the search bar's table view then I get a coredata exception :

Mapping nested IDs with RestKit in Xcode using Objective-C

不羁的心 提交于 2020-01-06 07:48:14
问题 I've got a webservice returning me a JSON formatted string looking like this : {"id":4, "name":"name", "image":1, "contacts":[2,3] } Where the contacts array contains primary key to other objects. I tried doing my mapping in this way : RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[OETGroup class] inManagedObjectStore:[RKObjectManager sharedManager].objectStore]; [mapping mapKeyPath:@"id" toAttribute:@"identifiant"]; [mapping mapKeyPath:@"name" toAttribute:@"name"]

Mapping nested IDs with RestKit in Xcode using Objective-C

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-06 07:47:04
问题 I've got a webservice returning me a JSON formatted string looking like this : {"id":4, "name":"name", "image":1, "contacts":[2,3] } Where the contacts array contains primary key to other objects. I tried doing my mapping in this way : RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[OETGroup class] inManagedObjectStore:[RKObjectManager sharedManager].objectStore]; [mapping mapKeyPath:@"id" toAttribute:@"identifiant"]; [mapping mapKeyPath:@"name" toAttribute:@"name"]

Must I explicitely enable exceptions in Xcode?

自古美人都是妖i 提交于 2020-01-06 07:21:15
问题 -objectWithID: is supposed to give me an object that's broken when the ID doesn't exist. The documentation says, that this object throws an exception when I try to access an property. However, it never throws any. Must I enable exceptions so that they're really thrown? Here's some code: // Assume: a new managed object has been created. Then it's ID has been converted to NSURL. // The MO has been saved. Then the NSURL has been converted back to an NSManagedObjectID *tmpID // So tmpID is an ID

Should I Use a FetchedResultsController for Objects in a Constantly Updating Relationship?

*爱你&永不变心* 提交于 2020-01-06 07:17:08
问题 I have a simple Coredata model with one entity called "conversation" and the other one "messages". Basically, I need to kind of reproduce the iPhone sms application. I have a to-one relationship from message to conversation and a to-many from conversation to messages. Conversation{ messages<-->>Message.conversation } Message{ conversation<<-->Conversation.messages } Anytime I launch my app, all my conversation are loaded in my fetchedResultsController. If I understood correctly how Coredata

How is the process called when getting persistent objects out of the persistent store?

风格不统一 提交于 2020-01-06 06:57:45
问题 "fetching ... " ... fetching what? Persistent objects? What's the scientific term when I send a request to an persistent store to get back an managed object? 回答1: You are fetching managed objects and their faults. 来源: https://stackoverflow.com/questions/2078222/how-is-the-process-called-when-getting-persistent-objects-out-of-the-persistent

Store NSInteger in Core Data

不羁的心 提交于 2020-01-06 05:39:25
问题 Is there any way I can skip dealing with NSNumber and work directly with NSInteger? 回答1: Core Data will only allow NSNumbers. However, you can write custom getters and setters to use NSInteger properties. mogenerator is a wonderful tool that does that automatically for you: it generates classes with native properties for all your entities. 回答2: No. NSInteger is just a typedef for a long integer, not an object. Actual implementation: #if __LP64__ || NS_BUILD_32_LIKE_64 typedef long NSInteger;

Problems with Float on core-data

依然范特西╮ 提交于 2020-01-06 05:28:46
问题 The following code largely inspired by some example I found on the net seems to work fine, with the core data entity called "Contact" and the property called "address" having an attribute String, in the xcdatamodel. It saves my data with no problem. Now my question is : how do I need to modify this code ? In order to make it work after I change the attribute of the property "address" from String to Float in the xcdatamodel. CoreDataTestOneAppDelegate *appDelegate = [[UIApplication