Ios 为Core.Data设置SQLite并在另一个线程中保存用户实体
当我的数据在另一个线程上执行时,如何在ios7中设置Core.Data数据库 我有这样的代码:Ios 为Core.Data设置SQLite并在另一个线程中保存用户实体,ios,objective-c,sqlite,core-data,ios7,Ios,Objective C,Sqlite,Core Data,Ios7,当我的数据在另一个线程上执行时,如何在ios7中设置Core.Data数据库 我有这样的代码: // Create thread dispatch_queue_t uniqueQueue = dispatch_queue_create("Unique Email Queue", NULL); // Run block on another thread called downloadQueue dispatch_async(uniqueQueue, ^{ // I have the
// Create thread
dispatch_queue_t uniqueQueue = dispatch_queue_create("Unique Email Queue", NULL);
// Run block on another thread called downloadQueue
dispatch_async(uniqueQueue, ^{
// I have the following strings that I want to save into a User entity that is already created
NSString *username = [emailStr lowercaseString];
NSString *password = passwordStr;
NSString *email = emailStr;
NSString *name = nameStr;
});
模型中我的实体用户创建了所有这些字段,并将createdOn和updatedOn日期设置为NSDate
如何初始化SQLite数据库并将该数据唯一地保存到数据库中?到目前为止,我已经尝试了很多不同的方法,比如使用AppDelegate,等等。一切都崩溃了
有一个好的答案吗
谢谢。发布您用于设置核心数据堆栈的代码。使用coredata进行多线程处理,嗯,我找到的最佳解决方案是Magic record。在这里尝试它和教程,那么在主线程中保存managedObjectContext和保存的数据是常见的做法吗?它会影响用户界面的响应性吗?