nsmanagedobject

“Error: this process has called an NSArray-taking method…” when iCloud pushes managed objects

无人久伴 提交于 2019-12-05 18:35:05
For every managed object that is sent via iCloud update, this warning/error is sent to the console: *** ERROR: this process has called an NSArray-taking method, such as initWithArray:, and passed in an NSSet object. This is being worked-around for now, but will soon cause you grief. My managed objects are Clients and have a one to many relationship with assessments as shown below. class Client: NSManagedObject { //other NSManaged vars are here @NSManaged var assessment: NSOrderedSet } Judging by the timing of this error (during ubiquitous updates) and the fact that this is my only use of NSSet

Can't get rid of compiler warnings for primitiveValue accessors in transient property getter impls

假装没事ソ 提交于 2019-12-05 17:50:54
I've implemented a transient property as below on one of the models in my app. It is declared in the model design as a transient property with undefined type. @property (nonatomic, readonly) NSNumberFormatter *currencyFmt; The current (warning-free) impl of this accessor is: - (NSNumberFormatter *) currencyFmt { [self willAccessValueForKey:@"currencyFmt"]; NSNumberFormatter *fmt = [self primitiveValueForKey:@"currencyFmt"]; [self didAccessValueForKey:@"currencyFmt"]; if (fmt == nil) { fmt = [[[NSNumberFormatter alloc] init] autorelease]; [fmt setNumberStyle:NSNumberFormatterCurrencyStyle];

Does an NSManagedObject retain its NSManagedObjectContext?

旧街凉风 提交于 2019-12-05 16:58:23
NSManagedObject provides access to its NSManagedObjectContext , but does it retain it? According to "Passing Around a NSManagedObjectContext on iOS" by Marcus Zarra , "The NSManagedObject retains a reference to its NSManagedObjectContext internally and we can access it." How does Zarra know this and is he correct? I'm asking because I want to know if the NSManagedObjectContext will be dealloc 'ed in the tearDown method below. (I'm using CocoaPlant .) #import <SenTestingKit/SenTestingKit.h> #import <CocoaPlant/CocoaPlant.h> #import "AccountUser.h" @interface AccountUserTests : SenTestCase {

How to set an initial value for @NSManaged property PFObject Subclass?

被刻印的时光 ゝ 提交于 2019-12-05 13:02:55
I have a subclass of PFObject called Attendee . In this class, there is a instance variable I have called isFavorite . Below is its class definition: @NSManaged var isFavorite: Bool This is an instance var that is local to the device and I never sync it up to the server. In addition, I never explicitly instantiate the Attendee class, but rather create it by typecasting from PFObject . I would like to set the above var to have an initial value of false . How would I achieve this? var isFavorite: Bool { get { if let isFavorite = self["isFavorite"] as? Bool { return isFavorite } return false /

Set auto increment in Core data iOS

狂风中的少年 提交于 2019-12-05 12:44:17
问题 I am using Core Data, and want to set an auto_increment ID as one of the fields which will be unique. Is it possible to set auto_increment in iOS using core data? Can anyone help me with a small example of how to implement this? Below is the code through which I am inserting records in database. In the first field "id", i want to set it as auto_increment and not manually insert it. - (NSManagedObjectContext *)managedObjectContext { NSManagedObjectContext *context = nil; id delegate = [

Core-Data: NSLog output Does Not Show “Fields”

一笑奈何 提交于 2019-12-05 10:49:42
I don't understand the output of NSLog for the array returned by a NSFetchRequest. I'm reading my database and placing the contents in an array, looping through the array and then outputting the contents with NSLog. I don't quite understand the output in the log file. Code below: -(void)createXMLFeed{ //Fetch details from the database. NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Tabrss" inManagedObjectContext:managedObjectContext]; [request setEntity:entity]; NSError *error; self.stories = [[managedObjectContext

Using property observers on NSManaged vars

喜你入骨 提交于 2019-12-04 23:47:09
I have a var declared in a class like so: @NSManaged var isFavorite: Bool I would like to declare a property observer, very similar to the one below. var organization: String { didSet { postNotificationWithName( "newData" ) } } However, Swift tells me that having property observers on NSManaged vars is not allowed. Is there any way I can implement such a feature or something similar for my isFavorite variable? Tom Harrington Yes-- delete the @NSManaged . It's not absolutely required, but if you delete it you unfortunately need to implement get and set for the property. You would need to add

CoreData: Fetching an Object from an unsaved Context

柔情痞子 提交于 2019-12-04 23:33:06
问题 after I insert a ManagedObject into a context I'd like to fetch it later but before saving the context (I'd save after all objects are inserted). It appears that querying the context later with a fetch concerning those objects returns nothing if the context wasn't previously saved. Is there a way to save only in the end ?(I guess i can save my objects in an array or dictionary and query that but i thought coredata would do this for me) 回答1: Try this: [myFetchRequest setIncludesPendingChanges

Can't instantiate subclass of NSManagedObject

笑着哭i 提交于 2019-12-04 23:00:17
问题 Xcode 6 has had a ton of bugs. But I'm not quite sure if this is a bug or not. It might not be since this is something I'm just now learning. My issue is, any time I try to instantiate my subclass of NSManagedObject, I do not have the option to pass the entity: NSEntityDescription and NSManagedContext: insertIntoManagedContext argument to the constructor, Xcode says "Extra Argument 'entity' in call" I created a new Xcode project from scratch, just to see if I could re-create the problem in a

How can I set a Custom attribute of an NSManagedObject which is calculated from other attributes?

两盒软妹~` 提交于 2019-12-04 16:01:23
问题 I am using core data framework to manage objects. I have an entity which has several attributes of decimal types. Among them is an attribute which is mathematically calculated from other attributes. Example: @interface Marks : NSManagedObject { } @property (nonatomic, retain) NSDecimalNumber * answerGradeA; @property (nonatomic, retain) NSDecimalNumber * answerGradeB; @property (nonatomic, retain) NSDecimalNumber * answerGradeC; @property (nonatomic, retain) NSDecimalNumber * total; Here I