mirror of
https://github.com/leanote/leanote-ios.git
synced 2025-11-28 01:05:27 +08:00
添加注释
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
|
||||
@implementation BaseService
|
||||
|
||||
static NSManagedObjectContext * context;
|
||||
static NSManagedObjectContext * writerContext;
|
||||
static NSManagedObjectContext * context; // 当前视图context
|
||||
static NSManagedObjectContext * writerContext; // 数据库context
|
||||
|
||||
// http://stackoverflow.com/questions/695980/how-do-i-declare-class-level-properties-in-objective-c
|
||||
+ (NSManagedObjectContext *) context {
|
||||
@@ -63,7 +63,7 @@ static NSManagedObjectContext * writerContext;
|
||||
push:(BOOL)push
|
||||
write:(BOOL)write
|
||||
{
|
||||
// 如果是privaate context, 则
|
||||
// 如果是private context, 则
|
||||
if(inContext != context) {
|
||||
NSError * savingError = nil;
|
||||
BOOL ok = [inContext save:&savingError];
|
||||
@@ -108,7 +108,8 @@ static NSManagedObjectContext * writerContext;
|
||||
return YES;
|
||||
}
|
||||
|
||||
// 得到临时context
|
||||
// 新建一个
|
||||
// 得到临时context, parent为context
|
||||
+ (NSManagedObjectContext *)getTmpContext
|
||||
{
|
||||
NSManagedObjectContext *temporaryContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// Leas.m
|
||||
// Leanote
|
||||
// Leanote单例Service, AppDelegate.m实例化, BaseService.context 为其tmpContext
|
||||
//
|
||||
// Created by life on 15/7/30.
|
||||
// Copyright (c) 2015年 Leanote. All rights reserved.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// SyncService.m
|
||||
// Leanote
|
||||
//
|
||||
// 每一次同步都会实例化Notebook, Note, Tag service, tmpContext传过去
|
||||
//
|
||||
// Created by life on 15/6/7.
|
||||
// Copyright (c) 2015 Leanote.com. All rights reserved.
|
||||
//
|
||||
@@ -355,6 +357,7 @@ BOOL inSyncing = NO;
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化各个service
|
||||
- (void) initService
|
||||
{
|
||||
_notebookService = [[NotebookService alloc] init];
|
||||
@@ -392,6 +395,8 @@ BOOL inSyncing = NO;
|
||||
+ (SyncService *) newSync
|
||||
{
|
||||
SyncService *syncService = [[SyncService alloc] init];
|
||||
|
||||
// 新建tmpContext
|
||||
syncService.tmpContext = [self getTmpContext];
|
||||
|
||||
[syncService initService];
|
||||
|
||||
Reference in New Issue
Block a user