nsmanagedobject

Why does an unsaved managedObject lose its managedObjectContext

女生的网名这么多〃 提交于 2019-12-11 12:38:02
问题 Currently, I am developing an app to book cars. All booking related data are stored in an entity 'Bookings'. As some attributes of 'Bookings' or relationships between 'Bookings' and other enties are mandatory I decided to add all managedObjects of entity 'Bookings' to their own managedObjectContext. This context will also be stored in a separate variable to avoid losing it. This works fine unless I'll sign (enterprise store or adhoc) my app and deploy it. ARC is enabled. Class Bookings

How to NSKeyedUnarchive subclasses of NSManagedObject to import into Core Data?

人盡茶涼 提交于 2019-12-11 09:17:19
问题 An existing document based application that saves and loads it's data using NSKeyedArchiver / NSKeyedUnarchiver is currently transformed to use Core Data as it's storage backend. Now I am trying to have a kind of import of files saved using the former application. The object structure didn't change, but I changed all objects to be NSManagedObject s. Now the initWithCoder: calls [super initWithCoder:] and doesn't create the object using NSEntityDescription . That failes epically (as expected).

Avoid fetching deleted NSManagedObjects

≡放荡痞女 提交于 2019-12-11 08:38:38
问题 Using NSFetchRequest , is it possible to avoid fetching a NSManagedObject that has been or will be deleted? I know it's possible to check -isDeleted or if -managedObjectContext returns nil, but is there a way to do this in the database layer? 回答1: Technically, if the object is truly deleted it will not show up at the database layer. What are the symptoms of the problem presenting as? 来源: https://stackoverflow.com/questions/9415071/avoid-fetching-deleted-nsmanagedobjects

Saving an updated Core Data instance [duplicate]

独自空忆成欢 提交于 2019-12-11 08:35:27
问题 This question already has answers here : How to update existing object in Core Data? (5 answers) Closed 5 years ago . In my iOS app I have a table view showing instances from a Core Data entity. After selecting a row, the app opens a view detail from the instance attributes values, and the user may change them if needed. From the table view controller I pass a NSManagedObject using the didSelectRowAtIndexPath method: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:

NSManagedObject unrecognized selector sent to instance

淺唱寂寞╮ 提交于 2019-12-11 07:36:10
问题 I have a Core Data model as follows, where children is a to-many relationship. .h @implementation MyEntity @dynamic name; @dynamic children; @end .m @interface MyEntity : NSManagedObject @property (nonatomic) NSString *name; @property (nonatomic) NSOrderedSet *children; @end I then try to set it using: MYAppDelegate *delegate = (MYAppDelegate *)[UIApplication sharedApplication].delegate; NSManagedObjectContext *managedObjectContext = [delegate managedObjectContext]; NSEntityDescription

EXC_BAD_ACCESS crash when updating NSManagedObject

非 Y 不嫁゛ 提交于 2019-12-11 06:25:30
问题 I have an application that pulls JSON data from a server, parses the data into NSManagedObject subclasses and these NSManagedObject subclasses are then used as properties in various view controllers. The trouble I'm having is that at some point in the future the data on the server will change and this will trigger an update pull request. When attempting to update the NSManagedObject subclasses, the app is crashing if the user then attempts to modify NSManagedObject via the UI by e.g.

Codable NSManagedObject fail on decodeIfPresent Data type

岁酱吖の 提交于 2019-12-11 06:01:17
问题 I obtain this error when i'm trying to decode this json: [{ "id": "76f22c25-cee7-4c7a-94fa-1fb85720f580", "purchaseDate": "2012-04-05T19:03:43Z", "title": "azare", }, { "id": "9b4b9f7d-382f-4555-9eaa-97939b13633f", "purchaseDate": "2012-04-05T19:02:46Z", "title": "Chocolat", }, { "id": "02a0aa06-2d0c-4ab9-aaaa-af7dee7b4845", "purchaseDate": "2012-09-24T17:39:52Z", "title": "Some thing", }] Fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.typeMismatch(Swift

RestKit 0.22 : how to map only firstObject of an array?

假如想象 提交于 2019-12-11 04:47:08
问题 I am receiving more data than needed: I only want to map first object of an array of objects. Using RestKit 0.22, how to map the following Json: { "name": "foobar", "tags": ["tag1", "tag2", "tag3"] } With the following model: @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *firstTag; To map name , I have this code: RKEntityMapping *mapping = [RKEntityMapping mappingForEntityForName:@"MyObjectModel" inManagedObjectStore:[RKManagedObjectStore defaultStore]];

Cancel NSOperation From NSOperationQueue

寵の児 提交于 2019-12-11 04:34:20
问题 I have downloaded information from an url, and I am sending this url as NSOperation in an NSOperationQueue, I want to know, how I can delete a specific NSOperation to download data for a specific url, now I am doing in this way: AppDelegate *appController = (AppDelegate *) [[UIApplication sharedApplication] delegate]; for (NSOperation *op in appController.seriesQueue.operations) { if ([op isKindOfClass:[MyDowndload class]]) { MyDownload *urlInDownload = (MyDowndload *)op; if ([urlInDownload

Swift linker error when accessing @NSManaged properties of a final class

心已入冬 提交于 2019-12-11 03:16:27
问题 I'm having issues in a larger project, and boiled it down to this simple code. For demo purposes, I have created a new Swift project with the following in a Model.swift file: import Foundation import CoreData class A: NSManagedObject { @NSManaged var foo: String } final class B: A { @NSManaged var bar: String } func testB(obj: B) -> String { return "\(obj.foo) \(obj.bar)" } This compiles, but the linker complains about accessing bar : Undefined symbols for architecture armv7: "_