core-data

Supporting a NSManagedObject fetchRequest() class method in iOS 9 and 10

[亡魂溺海] 提交于 2020-01-13 06:26:06
问题 iOS 10 introduced a new class-level fetchRequest() method in NSManagedObject . Like lots of other developers, I had created my own extension on NSManagedObject which had a fetchRequest() method. The compiler now rightly complains about this when I'm trying to build to support iOS 10 (with a deployment target of 9.0). What's a non-terrible way (i.e. I'm not renaming the method and all of the call points) to continue supporting iOS 9 and 10 with this codebase? The extension currently looks like

Supporting a NSManagedObject fetchRequest() class method in iOS 9 and 10

白昼怎懂夜的黑 提交于 2020-01-13 06:26:06
问题 iOS 10 introduced a new class-level fetchRequest() method in NSManagedObject . Like lots of other developers, I had created my own extension on NSManagedObject which had a fetchRequest() method. The compiler now rightly complains about this when I'm trying to build to support iOS 10 (with a deployment target of 9.0). What's a non-terrible way (i.e. I'm not renaming the method and all of the call points) to continue supporting iOS 9 and 10 with this codebase? The extension currently looks like

CoreData Application Freezes while performing a fetch Request pthread_mutex_lock

自古美人都是妖i 提交于 2020-01-13 05:41:29
问题 I am using Core Data for managing data base into my app. I can not post the code here, because its too lengthy. But I guess that I can explain my problem in small line of code along with some snap shots. +(NSArray *)checkusernameandpassword:(NSString *)entityname username:(NSString *)username password:(NSString *)password { managedobjectcontext=[Singleton sharedmysingleton].managedobjectcontext; NSEntityDescription *entity=[NSEntityDescription entityForName:entityname inManagedObjectContext

Core data crash occurring since iOS 10

懵懂的女人 提交于 2020-01-13 04:56:30
问题 I've been struggling to resolve a locally-unreproducible crash since iOS 10 within the sqlite/coredata library. It's occurring very infrequently - somewhere in the realm of 0.2% in production. What I know (or at least suspect): It only happens on iOS 10 and above. Most often occurs while saving the context, but may also be occurring during a core data fetch request. Occurring fairly rarely (ballpark rate of 0.15% of sessions) I have run stress tests with concurrency debug flags enabled, as

Core data executeFetchRequest consumes huge amounts of memory

喜你入骨 提交于 2020-01-13 04:30:27
问题 I am inserting cca 100 000 records in core data database. Database contains 3 entities. Player, Club, PlayerClub Entities are in relations: Player<-->>PlayerClub<<-->Club While inserting in PlayerClub I have noticed a lot of memory consumption and loss of speed after about 50 000 records have been inserted. Records are never updated cause PlayerClub has only unique values. For test reasons I have emptied Player and Club tables and run the program again. There was no speed drop but memory

How to simply delete old core data and rebuilt the new one?

纵然是瞬间 提交于 2020-01-13 02:15:56
问题 I tried to migrate coreData to new version, I'm following this step: Add a new Model Version (Select name.xcdatamodeld then Editor->Add model Version) before making any changes, if you have an app already submitted to App Store which is using the earlier model version. Then, Add a new file from Core Data Tab, as Mapping Model Select, Source Model (Model Version which the submitted App is using) Destination Model (Model Version in which you have done the Changes) source But my data mostly are

Deriving UITableView sections from NSFetchedResultsController using “to many” relationship

允我心安 提交于 2020-01-13 02:14:30
问题 My Core Data model looks like this: article <--->> category Is it even remotely possible to use NSFetchedResultsController to produce a UITableView that looks something like this? Category 1 - Article A - Article B - Article C Category 2 - Article A - Article D - Article E - Article F Category 3 - Article B - Article C Specifically, I'm interested in the (edge?) case where each UITableView section has a unique title (eg, "Category 1", "Category 2"), but the same object can exist in multiple

ios core data how to implement the sql transaction function?

▼魔方 西西 提交于 2020-01-12 18:49:42
问题 like title. I use core data to insert item, i insert 100 items , it`s too slow. How to up the insert speed? Core Data whicher has transaction funcation? 回答1: What you are looking for is to save in Core Data after all 100 objects have been inserted as opposed to after each insert. When objects are inserted into Core Data they are only present in memory. To persist your new objects to disc you should save which will take all changes (inserts, updates and deletes) and write them to disc together

What's the correct way to ship static (read-only) data in Core Data persistent store?

大憨熊 提交于 2020-01-12 10:10:08
问题 I want to ship static read-only data for use in my Core Data model. The problem is that there are obviously different persistent store types and I don't know if the format of those types is supposed to be opaque or if I'm supposed to be able to construct them by hand. Right now I just have a plist and it's very small (maybe 30 entries total). Should I just write code to import the plist into my data store when the app is first installed, or is there some way I can ship a hand-constructed

Store image in core data

怎甘沉沦 提交于 2020-01-12 10:00:10
问题 I want to store image for every employee while updating their records. How can I do that? I have a dictionary storing name, id and department of employees. Now i want the image to be saved together. 回答1: Core Data supports the "Binary Data" type - When you define a model with a Binary Data field, it creates your model class with an NSData field. You can move an image into the NSData field, and CoreData will save it for you. You can then use UIImage initWithData: to load the image from the