mirror of
https://github.com/leanote/leanote-ios.git
synced 2025-10-14 23:21:50 +00:00
解决添加用户后 crash
Notebook, Note, Tag controller的问题, 不明
This commit is contained in:
@@ -191,6 +191,7 @@ NSString const *key = @"isSelectOnSearchKey";
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 为了解决分隔线左侧少15px的情况, iphone, ipad都会存在
|
// 为了解决分隔线左侧少15px的情况, iphone, ipad都会存在
|
||||||
|
|
||||||
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
|
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
|
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
|
||||||
|
@@ -69,6 +69,15 @@ NSArray *users;
|
|||||||
[super didReceiveMemoryWarning];
|
[super didReceiveMemoryWarning];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) addUserSync
|
||||||
|
{
|
||||||
|
[Common showProgressWithStatus:NSLocalizedString(@"Add account successful and Synchronizing...", nil)];
|
||||||
|
// 同步
|
||||||
|
[SyncService incrSync:^(BOOL ok) {
|
||||||
|
[Common hideProgress];
|
||||||
|
} progress:nil];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) notifyChangeUser:(BOOL) isAdd
|
- (void) notifyChangeUser:(BOOL) isAdd
|
||||||
{
|
{
|
||||||
// 取得ios系统唯一的全局的广播站 通知中心
|
// 取得ios系统唯一的全局的广播站 通知中心
|
||||||
@@ -97,11 +106,9 @@ NSArray *users;
|
|||||||
|
|
||||||
// UITableViewRowAnimationBottom
|
// UITableViewRowAnimationBottom
|
||||||
if(isAdd) {
|
if(isAdd) {
|
||||||
[Common showProgressWithStatus:NSLocalizedString(@"Add account successful and Synchronizing...", nil)];
|
[self addUserSync];
|
||||||
// 同步
|
// 1s后同步
|
||||||
[SyncService incrSync:^(BOOL ok) {
|
// [self performSelector:@selector(addUserSync) withObject:nil afterDelay:1.0f];
|
||||||
[Common hideProgress];
|
|
||||||
} progress:nil];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[self showSuccessMsg:NSLocalizedString(@"Toggle account successful", nil)];
|
[self showSuccessMsg:NSLocalizedString(@"Toggle account successful", nil)];
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#import <SGNavigationProgress/UINavigationController+SGProgress.h>
|
#import <SGNavigationProgress/UINavigationController+SGProgress.h>
|
||||||
|
|
||||||
@interface NoteController ()<SWTableViewCellDelegate>
|
@interface NoteController()
|
||||||
|
|
||||||
@property (strong, nonatomic) NSIndexPath *indexPathToBeDeleted;
|
@property (strong, nonatomic) NSIndexPath *indexPathToBeDeleted;
|
||||||
@property (strong, nonatomic) NSFetchedResultsController *searchedResultsController;
|
@property (strong, nonatomic) NSFetchedResultsController *searchedResultsController;
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
|
|
||||||
// table的样式, 包括search table view
|
// table的样式, 包括search table view
|
||||||
[self setTableStyle:self.tableView];
|
[self setTableStyle:self.tableView];
|
||||||
[self setTableStyle:self.searchDisplayController.searchResultsTableView];
|
// [self setTableStyle:self.searchDisplayController.searchResultsTableView];
|
||||||
|
|
||||||
// isBlog ?
|
// isBlog ?
|
||||||
if(self.isBlog) {
|
if(self.isBlog) {
|
||||||
@@ -420,9 +420,6 @@
|
|||||||
// configure the cell
|
// configure the cell
|
||||||
Note *note = [fetched objectAtIndexPath:indexPath];
|
Note *note = [fetched objectAtIndexPath:indexPath];
|
||||||
|
|
||||||
[self.searchDisplayController.searchResultsTableView setSeparatorInset:UIEdgeInsetsZero];
|
|
||||||
[self.searchDisplayController.searchResultsTableView setLayoutMargins:UIEdgeInsetsZero];
|
|
||||||
|
|
||||||
static NSString *cellIdentifier2 = @"NoteCell2";
|
static NSString *cellIdentifier2 = @"NoteCell2";
|
||||||
NoteCell *cell2 = [tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
|
NoteCell *cell2 = [tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
|
||||||
if (cell2 == nil) {
|
if (cell2 == nil) {
|
||||||
@@ -730,9 +727,6 @@
|
|||||||
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
|
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
|
||||||
withRowAnimation:UITableViewRowAnimationFade];
|
withRowAnimation:UITableViewRowAnimationFade];
|
||||||
break;
|
break;
|
||||||
case NSFetchedResultsChangeUpdate:
|
|
||||||
case NSFetchedResultsChangeMove:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -112,7 +112,7 @@
|
|||||||
|
|
||||||
// table的样式
|
// table的样式
|
||||||
[self setTableStyle:self.tableView];
|
[self setTableStyle:self.tableView];
|
||||||
[self setTableStyle:self.searchDisplayController.searchResultsTableView];
|
// [self setTableStyle:self.searchDisplayController.searchResultsTableView];
|
||||||
|
|
||||||
// cate
|
// cate
|
||||||
if(self.delegate) {
|
if(self.delegate) {
|
||||||
@@ -695,9 +695,6 @@
|
|||||||
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
|
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
|
||||||
withRowAnimation:UITableViewRowAnimationFade];
|
withRowAnimation:UITableViewRowAnimationFade];
|
||||||
break;
|
break;
|
||||||
case NSFetchedResultsChangeMove:
|
|
||||||
case NSFetchedResultsChangeUpdate:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
#import "Leas.h"
|
#import "Leas.h"
|
||||||
#import "NoteController.h"
|
#import "NoteController.h"
|
||||||
|
|
||||||
@interface TagController ()<SWTableViewCellDelegate>
|
@interface TagController ()
|
||||||
|
|
||||||
// 从setting过来要用
|
// 从setting过来要用
|
||||||
@property (nonatomic, strong) Note *note;
|
@property (nonatomic, strong) Note *note;
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
|
|
||||||
// table的样式
|
// table的样式
|
||||||
[self setTableStyle:self.tableView];
|
[self setTableStyle:self.tableView];
|
||||||
[self setTableStyle:self.searchDisplayController.searchResultsTableView];
|
// [self setTableStyle:self.searchDisplayController.searchResultsTableView];
|
||||||
|
|
||||||
// cate
|
// cate
|
||||||
if(self.delegate) {
|
if(self.delegate) {
|
||||||
@@ -575,9 +575,6 @@
|
|||||||
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
|
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
|
||||||
withRowAnimation:UITableViewRowAnimationFade];
|
withRowAnimation:UITableViewRowAnimationFade];
|
||||||
break;
|
break;
|
||||||
case NSFetchedResultsChangeMove:
|
|
||||||
case NSFetchedResultsChangeUpdate:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
@implementation BaseService
|
@implementation BaseService
|
||||||
|
|
||||||
static NSManagedObjectContext * context;
|
static NSManagedObjectContext * context; // 当前视图context
|
||||||
static NSManagedObjectContext * writerContext;
|
static NSManagedObjectContext * writerContext; // 数据库context
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/695980/how-do-i-declare-class-level-properties-in-objective-c
|
// http://stackoverflow.com/questions/695980/how-do-i-declare-class-level-properties-in-objective-c
|
||||||
+ (NSManagedObjectContext *) context {
|
+ (NSManagedObjectContext *) context {
|
||||||
@@ -63,7 +63,7 @@ static NSManagedObjectContext * writerContext;
|
|||||||
push:(BOOL)push
|
push:(BOOL)push
|
||||||
write:(BOOL)write
|
write:(BOOL)write
|
||||||
{
|
{
|
||||||
// 如果是privaate context, 则
|
// 如果是private context, 则
|
||||||
if(inContext != context) {
|
if(inContext != context) {
|
||||||
NSError * savingError = nil;
|
NSError * savingError = nil;
|
||||||
BOOL ok = [inContext save:&savingError];
|
BOOL ok = [inContext save:&savingError];
|
||||||
@@ -108,7 +108,8 @@ static NSManagedObjectContext * writerContext;
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 得到临时context
|
// 新建一个
|
||||||
|
// 得到临时context, parent为context
|
||||||
+ (NSManagedObjectContext *)getTmpContext
|
+ (NSManagedObjectContext *)getTmpContext
|
||||||
{
|
{
|
||||||
NSManagedObjectContext *temporaryContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
|
NSManagedObjectContext *temporaryContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Leas.m
|
// Leas.m
|
||||||
// Leanote
|
// Leanote单例Service, AppDelegate.m实例化, BaseService.context 为其tmpContext
|
||||||
//
|
//
|
||||||
// Created by life on 15/7/30.
|
// Created by life on 15/7/30.
|
||||||
// Copyright (c) 2015年 Leanote. All rights reserved.
|
// Copyright (c) 2015年 Leanote. All rights reserved.
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
// SyncService.m
|
// SyncService.m
|
||||||
// Leanote
|
// Leanote
|
||||||
//
|
//
|
||||||
|
// 每一次同步都会实例化Notebook, Note, Tag service, tmpContext传过去
|
||||||
|
//
|
||||||
// Created by life on 15/6/7.
|
// Created by life on 15/6/7.
|
||||||
// Copyright (c) 2015 Leanote.com. All rights reserved.
|
// Copyright (c) 2015 Leanote.com. All rights reserved.
|
||||||
//
|
//
|
||||||
@@ -355,6 +357,7 @@ BOOL inSyncing = NO;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化各个service
|
||||||
- (void) initService
|
- (void) initService
|
||||||
{
|
{
|
||||||
_notebookService = [[NotebookService alloc] init];
|
_notebookService = [[NotebookService alloc] init];
|
||||||
@@ -392,6 +395,8 @@ BOOL inSyncing = NO;
|
|||||||
+ (SyncService *) newSync
|
+ (SyncService *) newSync
|
||||||
{
|
{
|
||||||
SyncService *syncService = [[SyncService alloc] init];
|
SyncService *syncService = [[SyncService alloc] init];
|
||||||
|
|
||||||
|
// 新建tmpContext
|
||||||
syncService.tmpContext = [self getTmpContext];
|
syncService.tmpContext = [self getTmpContext];
|
||||||
|
|
||||||
[syncService initService];
|
[syncService initService];
|
||||||
|
Reference in New Issue
Block a user