解决添加用户后 crash

Notebook, Note, Tag controller的问题, 不明
This commit is contained in:
life
2015-11-08 22:49:19 +08:00
8 changed files with 29 additions and 27 deletions

View File

@@ -191,6 +191,7 @@ NSString const *key = @"isSelectOnSearchKey";
}
// 线15px, iphone, ipad
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {

View File

@@ -69,6 +69,15 @@ NSArray *users;
[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
{
// ios广
@@ -97,11 +106,9 @@ NSArray *users;
// UITableViewRowAnimationBottom
if(isAdd) {
[Common showProgressWithStatus:NSLocalizedString(@"Add account successful and Synchronizing...", nil)];
//
[SyncService incrSync:^(BOOL ok) {
[Common hideProgress];
} progress:nil];
[self addUserSync];
// 1s
// [self performSelector:@selector(addUserSync) withObject:nil afterDelay:1.0f];
}
else {
[self showSuccessMsg:NSLocalizedString(@"Toggle account successful", nil)];

View File

@@ -23,7 +23,7 @@
#import <SGNavigationProgress/UINavigationController+SGProgress.h>
@interface NoteController ()<SWTableViewCellDelegate>
@interface NoteController()
@property (strong, nonatomic) NSIndexPath *indexPathToBeDeleted;
@property (strong, nonatomic) NSFetchedResultsController *searchedResultsController;
@@ -157,7 +157,7 @@
// table, search table view
[self setTableStyle:self.tableView];
[self setTableStyle:self.searchDisplayController.searchResultsTableView];
// [self setTableStyle:self.searchDisplayController.searchResultsTableView];
// isBlog ?
if(self.isBlog) {
@@ -420,9 +420,6 @@
// configure the cell
Note *note = [fetched objectAtIndexPath:indexPath];
[self.searchDisplayController.searchResultsTableView setSeparatorInset:UIEdgeInsetsZero];
[self.searchDisplayController.searchResultsTableView setLayoutMargins:UIEdgeInsetsZero];
static NSString *cellIdentifier2 = @"NoteCell2";
NoteCell *cell2 = [tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
if (cell2 == nil) {
@@ -730,9 +727,6 @@
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeUpdate:
case NSFetchedResultsChangeMove:
break;
}
}

View File

@@ -112,7 +112,7 @@
// table
[self setTableStyle:self.tableView];
[self setTableStyle:self.searchDisplayController.searchResultsTableView];
// [self setTableStyle:self.searchDisplayController.searchResultsTableView];
// cate
if(self.delegate) {
@@ -695,9 +695,6 @@
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeMove:
case NSFetchedResultsChangeUpdate:
break;
}
}

View File

@@ -17,7 +17,7 @@
#import "Leas.h"
#import "NoteController.h"
@interface TagController ()<SWTableViewCellDelegate>
@interface TagController ()
// setting
@property (nonatomic, strong) Note *note;
@@ -108,7 +108,7 @@
// table
[self setTableStyle:self.tableView];
[self setTableStyle:self.searchDisplayController.searchResultsTableView];
// [self setTableStyle:self.searchDisplayController.searchResultsTableView];
// cate
if(self.delegate) {
@@ -575,9 +575,6 @@
[tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeMove:
case NSFetchedResultsChangeUpdate:
break;
}
}

View File

@@ -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, parentcontext
+ (NSManagedObjectContext *)getTmpContext
{
NSManagedObjectContext *temporaryContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];

View File

@@ -1,6 +1,6 @@
//
// Leas.m
// Leanote
// LeanoteService, AppDelegate.m, BaseService.context tmpContext
//
// Created by life on 15/7/30.
// Copyright (c) 2015 Leanote. All rights reserved.

View File

@@ -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];