core-data

Is this a valid way of debugging CoreData concurrency issues?

随声附和 提交于 2021-02-19 03:43:10
问题 Like many iOS developers, I use CoreData, and like many iOS developers that use CoreData, I have hard-to-track-down thread violation errors. I'm trying to implement a debugging strategy for throwing exceptions when the CoreData concurrency rules are broken. My attempt is below - my question is, is this valid? Will it produce false positives? Summary: when an NSManagedObject is created, note the thread. Whenever a value is accessed later on, check if the current thread is the same as the

trying to save NSManagedObjectContext not working

跟風遠走 提交于 2021-02-18 22:09:05
问题 I have been trying to figure out this problem for 2 days now. I keep getting an error when I try to save. //self.data is NSManagedObject. kAppDelegate.moc is the managed object context. self.data = [NSEntityDescription insertNewObjectForEntityForName:@"Data" inManagedObjectContext:kAppDelegate.moc]; [self.data setValue:[NSNumber numberWithBool:NO] forKey:@"isit"]; [self.data setValue:@"" forKey:@"name"]; NSError *error; if(![self.data.managedObjectContext save:&error]) { NSLog(@"Save did not

Migrate iOS app group to another developer account

China☆狼群 提交于 2021-02-18 21:57:44
问题 I recently changed my developer account from company to individual. I have successfully transferred my applications, apart from the application groups. I cannot see anyway of transferring the existing app groups and my thoughts are that if I create a new app group, existing users will: Not be able to upgrade If they were able to upgrade, their existing data would be lost None of these situations look good unfortunately. Therefore in terms of TL;DR: How can I transfer app groups between

Unexpected Core Data Multithreading Violation

可紊 提交于 2021-02-18 20:40:36
问题 I'm using Apple's concurrency core data debugger. -com.apple.CoreData.ConcurrencyDebug 1 From time to time I got __Multithreading_Violation_AllThatIsLeftToUsIsHonor__ , even I'm almost sure threading is not violated. This is part of code where exception occurs (code is part of protocol that extends NSManagedObject): public static func find(arrayBy predicate: NSPredicate, sort: [NSSortDescriptor] = [], limit: Int? = nil) -> [Self] { let fetchRequest = NSFetchRequest<Self>(entityName: "\(Self

CoreData backgroundContext save doesn't save and is lost

若如初见. 提交于 2021-02-11 17:39:39
问题 I'm having a problem saving things in the background. So I have 2 operations that I chain with RxSwift. The first items are saved and when I fetch them on a main context all the information is there. But in the second operation I fetch the same object and I update it with more information. Now whatever I do there it never updates the entity. This is my coredata code: class CoreDataStack { static let modelName = "Mo_Application" static let model: NSManagedObjectModel = { let modelURL = Bundle

CoreData backgroundContext save doesn't save and is lost

半世苍凉 提交于 2021-02-11 17:39:39
问题 I'm having a problem saving things in the background. So I have 2 operations that I chain with RxSwift. The first items are saved and when I fetch them on a main context all the information is there. But in the second operation I fetch the same object and I update it with more information. Now whatever I do there it never updates the entity. This is my coredata code: class CoreDataStack { static let modelName = "Mo_Application" static let model: NSManagedObjectModel = { let modelURL = Bundle

Swift: @objc(…) Attribute

荒凉一梦 提交于 2021-02-11 17:10:45
问题 In Apple-generated code (Core Data NSManagedObject subclasses, for example) I see this: @objc(LPFile) public class LPFile: NSManagedObject { ... } My question is: why is the @objc declaration done as above, instead of: @objc public class LPFile: NSManagedObject { ... } or @objcMembers public class LPFile: NSManagedObject { ... } What is special about the separate @objc(identifier) declaration? I can't seem to find documentation about it and googling just turns up the other two approaches.

Swift: @objc(…) Attribute

半世苍凉 提交于 2021-02-11 17:10:12
问题 In Apple-generated code (Core Data NSManagedObject subclasses, for example) I see this: @objc(LPFile) public class LPFile: NSManagedObject { ... } My question is: why is the @objc declaration done as above, instead of: @objc public class LPFile: NSManagedObject { ... } or @objcMembers public class LPFile: NSManagedObject { ... } What is special about the separate @objc(identifier) declaration? I can't seem to find documentation about it and googling just turns up the other two approaches.

Swift: @objc(…) Attribute

ⅰ亾dé卋堺 提交于 2021-02-11 17:08:44
问题 In Apple-generated code (Core Data NSManagedObject subclasses, for example) I see this: @objc(LPFile) public class LPFile: NSManagedObject { ... } My question is: why is the @objc declaration done as above, instead of: @objc public class LPFile: NSManagedObject { ... } or @objcMembers public class LPFile: NSManagedObject { ... } What is special about the separate @objc(identifier) declaration? I can't seem to find documentation about it and googling just turns up the other two approaches.

fetchRequest is null when calling second time

和自甴很熟 提交于 2021-02-11 15:56:20
问题 The code is let request: NSFetchRequest<NSFetchRequestResult> = Item.fetchRequest() print(request) Item is an entity of Core Data. The first execution is correct, but when execute it again error occurs Thread 12: EXC_BAD_ACCESS (code=1, address=0x0) . The following is logs: This is a similar question, but with Object C. It says that defining managedObjectContext in view controller directly instead of transferring it from AppDelegate can fix the bug. In my code, the managedObjectContext is in