core-data

Swift: Store arrays of custom classes in Core Data

时光怂恿深爱的人放手 提交于 2020-01-22 14:56:48
问题 I'm new to Core Data but for a new project of mine, I would like to save my data to Core Data. I want to create a Reptile-class which contains a couple of custom class arrays. Without Core Data I would have something like this: import Foundation import UIKit class Reptile_ { private var _name: String? private var _dateOfBirth: String? private var _morph: String? private var _breed: String? private var _feedingPeriodInDays: Int? private var _reminderTime: NSDate? private var

In Core Data, what is the URI property type on the NSManaged object supposed to be used for?

[亡魂溺海] 提交于 2020-01-22 14:19:26
问题 Why would you need the URI type? What is the equivalent Swift object type for a URI property? Would I store a URL in this property? I'm doubtful that I would ever want to store the URI for another managed object in this way, but is it related? Also, a link to any Apple docs that describe the usage would be helpful. 回答1: In the WWDC 2017 "What's New in Core Data" session, one of the slides indicates: Why would you need the URI type? To store a URL. What is the equivalent Swift object type for

In Core Data, what is the URI property type on the NSManaged object supposed to be used for?

你离开我真会死。 提交于 2020-01-22 14:19:22
问题 Why would you need the URI type? What is the equivalent Swift object type for a URI property? Would I store a URL in this property? I'm doubtful that I would ever want to store the URI for another managed object in this way, but is it related? Also, a link to any Apple docs that describe the usage would be helpful. 回答1: In the WWDC 2017 "What's New in Core Data" session, one of the slides indicates: Why would you need the URI type? To store a URL. What is the equivalent Swift object type for

Magical Record, saving, and NSFetchedResultsController

对着背影说爱祢 提交于 2020-01-22 12:27:36
问题 Not sure if this is an issue with the way Magical Record does saves, or I'm just making an noob mistake somewhere. I'm using an NSFetchedResultController (FRC) and UITableView to display a list of entities, when the user taps "Add" a new View Controller with an editor is pushed, a new entity is created with [MyEntity MR_createEntity] . The user can add additional entities here that are added to the main entity via a relationship. When the user taps "Save" in this View Controller the context

CoreData ManagedObjectContext Recursive Save Error

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-22 10:40:06
问题 Some users of mine are encountering a CoreData error when performing a save. I haven't been able to find any information online about this error or how to symbolicate the stack trace. The error message is attempt to recursively call -save: on the context aborted, stack trace , with the full error message below. Doe anyone have any hints or ideas on how to figure out what is going wrong? Error Domain=NSCocoaErrorDomain Code=132001 "(null)" UserInfo={message=attempt to recursively call -save:

CoreData ManagedObjectContext Recursive Save Error

别来无恙 提交于 2020-01-22 10:39:08
问题 Some users of mine are encountering a CoreData error when performing a save. I haven't been able to find any information online about this error or how to symbolicate the stack trace. The error message is attempt to recursively call -save: on the context aborted, stack trace , with the full error message below. Doe anyone have any hints or ideas on how to figure out what is going wrong? Error Domain=NSCocoaErrorDomain Code=132001 "(null)" UserInfo={message=attempt to recursively call -save:

NSManagedObject changes do not trigger objectWillChange

假如想象 提交于 2020-01-22 10:34:07
问题 I have a Core Data model with an entity generated into class Task . I am trying to get the Combine publisher objectWillChange from the NSManagedObject to send (automatically, without manual work), but it won't. The task entity has a name attribute. let task = Task(context: container.viewContext) let taskSubscription = task.objectWillChange.sink(receiveValue: { _ in print("Task changed") }) task.name = "Foo" // WILL NOT trigger If I call send manually, the subscription will work: task

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 =

Matt Gallagher's UITableView (Revisited) + NSFetchedResultsController

一世执手 提交于 2020-01-22 04:45:46
问题 If you look at Matt Gallagher's Cocoa With Love blog, he has a brilliant discussion (with sample code) on a fresh a beautiful retake on UITableView ... In the post, he talks about it's great many benefits of animations and heterogeneous cells, etc. However, one of the limitations he lists is a bit of a show-stopper for me. It won't work with NSFetchedResultsController. The design of loading data into the cells assumes that all that data is static and available immediately. However, if you are

Save and Load Data - CoreData

微笑、不失礼 提交于 2020-01-21 07:53:08
问题 I am very new to CoreData and in my iPhone app I want to know how to save some text, then load it back in. But the trick is, loading it back in when the date in the UIDatePicker is the same as when I saved it, like a calendar. Hope you can help in anyway. Its pretty important I learn how to do this fairly soon, so any help is massively appreciated, thanks. UPDATE: Thanks for the replies, especially the for the code sample. However I have some issues understand how this fits together, forgive