nsfetchrequest

executeFetchRequest:error: freezes app

此生再无相见时 提交于 2019-12-21 21:42:11
问题 I don't know what it is but it happens when is fetching elements, well that's what I asume because the app just freezes, I pause the debugging and the debugger stops at a return [__context executeFetchRequest:request error:&error]; Any help about this will be very appreciated. 回答1: Check this post basically you'll need to lock your persistentStoreCordinator because read only calls aren't thread safe. Apple documentation mention this here. Cheers my friend! 来源: https://stackoverflow.com

countForFetchRequest in Swift 2.0

萝らか妹 提交于 2019-12-21 09:35:21
问题 I am trying to use the countForFetchRequest method on a managed object context in Swift 2.0. I note that the error handling for executeFetchRequest has been changed across to the new do-try-catch syntax: func executeFetchRequest(_ request: NSFetchRequest) throws -> [AnyObject] but the countForFetchRequest method still uses the legacy error pointer: func countForFetchRequest(_ request: NSFetchRequest, error error: NSErrorPointer) -> Int ...and I am having a bit of trouble figuring out how to

Core Data: Keypath Error Not Found in Entity <NSSQLEntity Studies id=3>

你离开我真会死。 提交于 2019-12-21 07:08:51
问题 Could any one tell me what's the wrong with this code? It raises the following error and cause application to crash: reason: 'keypath Studies.patients.PatientName not found in entity <NSSQLEntity Studies id=3>' Code: - (void)viewDidLoad { [super viewDidLoad]; test_coredataAppDelegate *appDelegate = (test_coredataAppDelegate *)[[UIApplication sharedApplication] delegate]; self.context = appDelegate.managedObjectContext; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

Variable Substitution with FetchRequests stored in a CoreData Model

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 04:22:06
问题 I've always created my NSFetchRequests entirely in-code. Now I'm looking at the Xcode GUI for building a fetch request and storing it in the model. I'm following an example from the Xcode Documentation. I added a Fetch Request to my model, and the predicate that has been created through the Modelling GUI is: firstName LIKE[c] "*SUBSTRING*" I then retrieve that request with these two lines: NSDictionary *substituionDictionary = [NSDictionary dictionaryWithObject:@"woody" forKey:@"SUBSTRING"];

iOS中CoreData数据管理系列三——添加与查询数据

帅比萌擦擦* 提交于 2019-12-20 16:43:09
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> iOS中CoreData数据管理系列三——添加与查询数据 一、引言 在前两篇博客中,分别介绍了iOS中CoreData框架创建数据模型和CoreData框架中的三个核心类。博客地址如下: iOS中CoreData框架简介: http://my.oschina.net/u/2340880/blog/610488 。 CoreData框架中三个核心的类: http://my.oschina.net/u/2340880/blog/610948 。 本篇博客将综合使用三个核心的类,进行数据创建和查询的操作介绍。 二、建立数据对象类 前面博客介绍的NSManagedObjectModel是数据管理模型,可以将其类比如数据库,NSManagedObjectModel中存放着数据库的结构信息。 NSEntityDescription是实体描述对象,它可以类比如数据库中的表, NSEntityDescription存放的是表的结构信息。这些类都是一些抽象的结构类,并不存储实际每条数据的信息,具体的数据由NSManagedObject类来描述,我们一般会将实体类化继承于NSManagedObject。 Xocde工具提供了快捷的实体类化功能,还拿我们一开始创建的班级与学生实体来演示,点击.xcdatamodeld文件

Core Data search optimization

感情迁移 提交于 2019-12-20 16:20:10
问题 I'm working on a search feature in one of my Core Data based apps and I'm trying to gather everyone's tips on search optimization to get it as fast as I possibly can. The search needs to be fast enough that it can deliver near-instantaneous results for database of 20,000+ objects. What I've done so far (as far as optimization goes) Implemented the technique shown in WWDC 2010 session 137, creating a keyword entity and creating a to-many relationship from my main object entities to it. The

Core Data search optimization

烂漫一生 提交于 2019-12-20 16:18:51
问题 I'm working on a search feature in one of my Core Data based apps and I'm trying to gather everyone's tips on search optimization to get it as fast as I possibly can. The search needs to be fast enough that it can deliver near-instantaneous results for database of 20,000+ objects. What I've done so far (as far as optimization goes) Implemented the technique shown in WWDC 2010 session 137, creating a keyword entity and creating a to-many relationship from my main object entities to it. The

CoreData get parent of child

我的未来我决定 提交于 2019-12-20 07:28:29
问题 I have a one-to-many relationship store <---->> product , and I know the product, how can I find out who the parent of this product is? I can have many products with the same values, for example product1 has parent1 and another product with the same values as product1 has parent2 so i cant't search which parent contains product1 ? 回答1: You should have noticed the core data model editor bugging you about the relationship not having an inverse relationship if you don't have one. If you do have

NSFetchRequest for groupby and count combination

不打扰是莪最后的温柔 提交于 2019-12-20 07:11:56
问题 I'm new in Core Data, so i want to write simple fetch request to group result by some field and also a count of another field in that group. so for example i have products table i want to retrieve all grouped products by date and the count of product, the simple query in sql is like SELECT DateRegistered,Count(*) FROM Products Group By DateRegistered 回答1: Your best bet is the very flexible NSFetchedResultsController . You would have a fetch request that simply fetches the Product entity

Show distinct results in fetch request, group by an attribute and calculate the total for that attribute

本秂侑毒 提交于 2019-12-20 02:00:14
问题 Scenario: I have an expense tracking iOS Application and I have a view controller called "DashBoardViewController" (table view controller - with FRC) which would basically categorize my expenses/incomes for a given week, a month, or year and display it as the section header title for example : (Oct 1- Oct 7, 2012) and it shows expenses/incomes ROWS and related stuff according to that particular week or month or year. My Question: What I want to accomplish is : Suppose I save 3 new expenses