core-data

Problem creating NSManagedObject derived class

空扰寡人 提交于 2020-01-05 05:57:10
问题 I am doing something wrong here... I know that I'm using Xcode and I have created the following class using the data modeller: #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @interface Project : NSManagedObject { @private } @property (nonatomic, retain) NSNumber * indent; @property (nonatomic, retain) NSNumber * collapsed; @property (nonatomic, retain) NSString * color; @property (nonatomic, retain) NSNumber * project_id; @property (nonatomic, retain) NSNumber * item_order;

Best way to implement Enums with Core Data in Swift

孤街浪徒 提交于 2020-01-05 05:24:30
问题 Very similar question to Best way to implement Enums with Core Data What is the best way to bind Core Data entities to enum values so that I am able to assign a type property to the entity? In other words, I have an entity called Item with an itemType property that I want to be bound to an enum, what is the best way of going about this in Swift ? 回答1: So far, this is my best approach. I still use the ObjC enum definition, as suggested in Daniel Eggert's answer to the same ObjC question as the

NSPersistentStoreCoordinator has no persistent stores(Schema mismatch or migration failure) core data in ios iOS

僤鯓⒐⒋嵵緔 提交于 2020-01-05 04:58:09
问题 I have added new version of the data model. I added new fields in new version.Also set current Model Version to newly created Version. Code update: - (NSManagedObjectModel *)managedObjectModel { if (_managedObjectModel != nil) { return _managedObjectModel; } NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"PPUSFAModel" withExtension:@"momd"]; //I earlier was PPUSFAModel 16, i added new model version PPUSFAModel 17. _managedObjectModel = [[NSManagedObjectModel alloc]

xcodebuild: cdtool cannot compile: DataModelCompile /path/to/coredatamodel.xcdatamodeld dyld: Symbol not found: _OBJC_CLASS_$_OS_object

时光毁灭记忆、已成空白 提交于 2020-01-05 04:16:05
问题 I'm building a Mac Desktop/Cocoa Application to archive my iOS project, the core implementation uses NSTask with xcodebuild command, followed by raywenderlich's this guide. The root cause is the CoreData model file compile, I used this app to build my another project which didn't contain any CoreData files and no issue there. More interesting comparison is, I tried the same xcodebuild command in my terminal and it just succeed! Then I start to diff the two xcodebuild output and found some

Core Data Sort Fetched Request

别说谁变了你拦得住时间么 提交于 2020-01-05 03:47:07
问题 I need to fetch my database and order it by id. So for example, i have 2 columns in database, database_id and content. When I NSLOG last line i get all rows of "content" column. But I need to sort those "content" rows based on database_id which is 1,2,3,4,5,6 (ascending). Help ??? NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *ent = [NSEntityDescription entityForName:@"databaseName" inManagedObjectContext:self.managedObjectContext]; [request setEntity:ent];

How do I generate code (or find the code generated) for fetch requests I created graphically using the data model editor in Xcode 4.x?

倖福魔咒の 提交于 2020-01-05 03:16:15
问题 I can see where the code goes for the Entities, as NSManagedObject specialized classes, that was very straightforward. Bu t I do not see generated code or an option to generate code for visually designed fetch requests. 回答1: There is no actual "code" but just serialized NSFetchRequest objects in the data model file. You can get the NSFetchRequest objects themselves which you can query for their predicates and the like. For fetch templates use -[NSMangedObjectModel fetchRequestTemplateForName:

How to show detailed info inside NSLog in CoreData? suggest me a solution

怎甘沉沦 提交于 2020-01-05 02:32:33
问题 I am using foliowin function to fetch all records in application -(NSArray*)recordsInTable:(NSString*)tableName andManageObjectContext:(NSManagedObjectContext *)manageObjContext { NSError *error=nil; // **** log objects currently in database **** // create fetch object, this object fetch's the objects out of the database NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName: tableName inManagedObjectContext

UITableView In Edit Mode - Pressing Delete Makes My App Crash

瘦欲@ 提交于 2020-01-04 14:21:27
问题 My UITableView has an Edit button which adds an "insert row" (with a green plus). If I try to delete a row while in Edit mode, my app crashes with "NSRangeException". Deleting a row while NOT in edit mode (using swipe-to-delete) is fine. I know this is to do with how many rows the table view thinks it has - getting an insert row and swipe-to-delete both to work in the same table is a nightmare (for a beginner like me) because both swiping and pressing the edit button put the table in "edit

UITableView In Edit Mode - Pressing Delete Makes My App Crash

ⅰ亾dé卋堺 提交于 2020-01-04 14:21:07
问题 My UITableView has an Edit button which adds an "insert row" (with a green plus). If I try to delete a row while in Edit mode, my app crashes with "NSRangeException". Deleting a row while NOT in edit mode (using swipe-to-delete) is fine. I know this is to do with how many rows the table view thinks it has - getting an insert row and swipe-to-delete both to work in the same table is a nightmare (for a beginner like me) because both swiping and pressing the edit button put the table in "edit

Managed Objects have different id when fetched

别说谁变了你拦得住时间么 提交于 2020-01-04 13:48:19
问题 im working with coredata and there is a concept that im not getting; i've 2 managed objects ACConversation and ACMessages with a one to many relationship, so i'm saving a message associated to a conversation and trying to fetch them back based on: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.conversation = %@", self.conversation]; but the id associated to the object is different (it seems more a memory address) and with the above predicate it doesnt fetch anything: 2013-01