nsmanagedobject

Detecting changes to a specific attribute of NSManagedObject

二次信任 提交于 2019-12-31 09:21:47
问题 How can I detect changes to a specific attribute of an NSManagedObject ? In my Core Data data model, I have a Product entity that represents a product for sale. The Product entity has several attributes: price , sku , weight , numberInStock , etc. Whenever the price attribute of a Product changes, I need to perform a lengthy calculation. Consequently, I would like to know when the price attribute of any Product changes, [edit] even if that change comes from merging a context saved on another

NSPredicate for an NSManagedObject's string attribute's length

和自甴很熟 提交于 2019-12-28 18:29:52
问题 Could someone please help me define a predicate that returns only NSManagedObject's who's "letters" attribute length is within a certain range? Here's the example I've been trying, I've got a feeling it's the letters.length notation, I've also tried the kvc letters.@length with no success.. What am I doing wrong? NSManagedObjectContext *context = ...; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Word"

invalid redeclaration in auto code generate NSManagedObject Subclass Swift 3

半城伤御伤魂 提交于 2019-12-28 11:48:16
问题 Using Version 8.1 of Xcode. Create an entity named "MapRegionObject" in .xcdatamodeld file. Using auto code generator, click Editor on the navigation bar -> create NSManagedOject Subclass... Got two files : MapRegionObject+CoreDataClass.swift and MapRegionObject+CoreDataProperties Errors in two files showing in the screenshot: MapRegionObject+CoreDataClass.swift MapRegionObject+CoreDataProperties Please help me fix this bugs, thank you so much! 回答1: In Xcode 8.1, before using the auto code

CoreData: warning: Unable to load class named

雨燕双飞 提交于 2019-12-27 10:37:35
问题 I am duplicating an existing Objective-C TV Show app to a new Swift version using Xcode 6.1 and am having some issues with CoreData. I have created a model of 4 entities, created their NSManagedObject subclass (in Swift), and all files have the proper app targets set (for 'Compile Sources'). I am still getting this error whenever I try to insert a new entity: CoreData: warning: Unable to load class named 'Shows' for entity 'Shows'. Class not found, using default NSManagedObject instead. A few

How to add additional objects with fetch result controller fetched objects list?

家住魔仙堡 提交于 2019-12-25 19:57:37
问题 I have an entity called “Event“ which has s start and end date properties. I have to show the list of events by grouping them by date in UI. I am using NSFetchedResultsController to fetch and list the events. Let's assume an event has start date today and end date tomorrow, here I need to show this event on two different dates in UI but I will have only one entry in the database. I really don’t want to create multiple entries for an event and also I wish to use fetch result controller as it

How to output a view hierarchy & contents to file?

假如想象 提交于 2019-12-25 06:59:02
问题 I'm writing a glorified 'paint' application where a user can paste in images, and draw a bunch of UIBezier curves, and move all these things around and rotate them. Most of these are implemented by stacking UIImageViews and (sub-classed) UIViews as subviews onto the main view in the view controller. I want the user to be able to save the state of their creation as some kind of file and share it with others (e.g. via DropBox). The saving itself isn't the issue (I know how to save files!), just

How to create dateComponents from Date stored in CoreData

╄→尐↘猪︶ㄣ 提交于 2019-12-24 21:52:18
问题 I am trying to create dateComponents from Date stored in CoreData from UIDatePicker. However, I am not able to make it. I am first converting Date which is stored in editnotes?.sSelectedDate into dateComponents and then using the dateComponents for triggering my notifications. Here is what I am doing: var date = Date() if let editnote = editnotes { date = editnote.sSelectedDate } else { print("nil") } let calendar = NSCalendar.current let unitFlags = Set<Calendar.Component>([.day, .month,

Accessing data in retrieved Managed Object with Core Data

穿精又带淫゛_ 提交于 2019-12-24 15:33:38
问题 I'm trying to access a data in the retrieved Managed Object. Xcode giving me error "Cannot subscript a value type "[AnyObject]?" with an index of type 'int'". Doesn anybody know what I should do to? Thank you This is my method which saves data and which is called from my viewDidLoad method: // save data func saveData (jmeno:String, adresa:String, telefon:String) { // delegate let delegate = UIApplication.sharedApplication().delegate as! AppDelegate // managed object context let

NSManagedObject values are correct, then incorrect when merging changes from parent to child NSManagedObjectContext

不问归期 提交于 2019-12-24 13:16:06
问题 I’m having a Core Data issue while using 2 NSManagedObjectContext , running on different threads, and migrating changes from the parent to the child. In essence, I’m able to pull the changes from parent to child, but immediately after doing so, the changes are lost. The app I’m building is a test for syncing a model between multiple devices and a server. The context that holds the objects the user interacts with is on the main thread and is configured as a child of the sync context and is

Issue with Core Data attribute returning 0 [duplicate]

痞子三分冷 提交于 2019-12-24 10:18:53
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Core Data not saving NSString. Hey all! Currently experiencing a weird issue with Core Data in my latest application. Basically what I'm accomplishing is that of parsing JSON and adding each object into Core Data under the respective attribute. This works fine as far as I can see from the NSLogs I have set in place. However, when it comes to displaying one of the values in a UITableView, it always returns 0 for