nsmanagedobject

Use NSManagedObject class without initWithEntity:?

走远了吗. 提交于 2019-11-27 16:20:25
问题 My problem is similar to: Problem creating NSManagedObject derived class I have setup a NSManagedObject in Core Data and have a class for it. However, instead of creating an identical NSObject class, I'd like to use the NSManagedObject class, but I don't want to create the entity and save it. I just want to use it for an array, only when I need to save the object in Core Data do I want to use insertEntity: Store *store = [[Store alloc] init]; It's giving me the following error: CoreData:

Duplicate Symbol Error in NSManagedObject Subclass

爷,独闯天下 提交于 2019-11-27 16:11:20
I just simply created a demo project with Core Data. I created an entity Userinfo in my data model. Now I created a NSManagedObject subclass of this entity. Xcode autogenerated these 4 classes. Now when I build the project it throws this error: I have done everything I know to remove the error of duplicacy but nothing helped. I think its a Xcode bug. Please help. shallowThought You are generating files which have already been generated for you by Xcode and thus get duplicate declarations. Details about this feature (new in Xcode 8) can be found in this WWDC video . Two possible fixes: 1) Use

Setting up a parent-child relationship in Core Data

纵饮孤独 提交于 2019-11-27 13:49:31
I'm trying to set up a relationship in Core Data. I have a list of Trees, and each Tree will have a list of Fruits. So I have a Tree entity and a Fruit entity. In code, I will want to list the Trees, in a table view for example. When you click on a Tree, it should then display a list of fruits that growing on that Tree. How do I set up this relationship? Do I need to give the Fruit an attribute called tree? And how do I set the relationship in code, for example when I create a Fruit how do I associate it with a given Tree ? Soleil, This is quite simple. First of of all, your model should look

Swift + CoreData: Cannot Automatically Set Optional Attribute On Generated NSManagedObject Subclass

一曲冷凌霜 提交于 2019-11-27 12:18:05
I have a coredata entity named Record and has a property dateUpdated. I noticed that the generated NSManagedObject subclass has no optional mark (?) CoreData Editor: Generated Subclass: Expected: UPDATED: It's tedious in my part, because each time I want to regenerate the subclasses, it means I also need to update all optional values manually. Having a non-optional (without '?') in subclass lead me to check evalue before assigning, like example below: // sample value: // serverDateFormatter = "yyyy/MM/dd" // dateString = "" // Branch is a subclass of Record (see above images) var date = self

Core data images from desktop to iphone

大城市里の小女人 提交于 2019-11-27 11:00:21
问题 I built a simple mac data entry tool I use with an iPhone application. I've recently added thumbnail which I added via an Image Well using simple bindings. Its a transformable data type which seems to work fine. The iPhone application however won't show the images. The attribute isn't null but I can't get an image to appear. The following is for cellForRowAtIndexPath static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]

Xcode4: Different code generated for custom core data managed objects

谁说我不能喝 提交于 2019-11-27 10:38:04
问题 Now that Xcode4 is publicly available I'm moving this question out of Apple's secret dev forum: Can someone explain why the code generated in the following procedure is different than in Xcode3? Is the code better or might this be a bug? I use Core Data custom managed classes and this was the procedure I followed in Xcode3: Go to the model editor Select the entity you wish to generate source code for Go to File->New->New Files Choose managedobject class (or whatever it was, I can't open

How do I copy or move an NSManagedObject from one context to another?

試著忘記壹切 提交于 2019-11-27 10:14:44
I have what I assume is a fairly standard setup, with one scratchpad MOC which is never saved (containing a bunch of objects downloaded from the web) and another permanent MOC which persists objects. When the user selects an object from scratchMOC to add to her library, I want to either 1) remove the object from scratchMOC and insert into permanentMOC, or 2) copy the object into permanentMOC. The Core Data FAQ says I can copy an object like this: NSManagedObjectID *objectID = [managedObject objectID]; NSManagedObject *copy = [context2 objectWithID:objectID]; (In this case, context2 would be

Core Data merge two Managed Object Context

余生长醉 提交于 2019-11-27 09:29:59
问题 My Cocoa/Application has a Managed Object Context on the main thread. When I need to update my data my program will: Start a new thread Receive new data from a server Create a new Managed Object Context Send a notification to the main thread in order to merge the two context This is the function that receive the notification on the main thread - (void)loadManagedObjectFromNotification:(NSNotification *)saveNotification { if ([NSThread isMainThread]) { [self.managedObjectContext

NSPrivateQueueConcurrencyType Not saving properly

£可爱£侵袭症+ 提交于 2019-11-27 09:21:50
The following method gets called in order to populate my Core-Data after AFNetworking fetches information from my app server. The information seems to be perfectly working as when the table is updated I can see the new information being updated in the UITableView . Now the problem that I have is that even tho I can see the information ( after it has been fetches from the server, stored into Core-data and refetches to display in my UITableView ) If I then go and close my app and re open it, the information is not there anymore. It seems as if the information is not persistent and the problem

iPhone App floating point calculations when released to the app store.

百般思念 提交于 2019-11-27 08:35:14
问题 I released my first solo iPhone app last week that calculates 12V Marine and Boat Battery usage. I had tested it vigorously on the simulator and on my iPhone, and when I was comfortable all was well, I archived the app and released it to Apple. When users started using the app, they noted a calculation was not working as expected. The below code, which is a method on a NSManagedObject model, was producing a DIFFERENT output when released to when in debug. The below should sum up the total of