From df646568d61fdd8d2118763a5e093f5bf54e6343 Mon Sep 17 00:00:00 2001 From: Wongzigii Date: Sat, 22 Aug 2015 12:17:22 +0800 Subject: [PATCH 1/5] Adopt protocol properly --- Leanote/controller/auth/LoginViewController.m | 2 +- Leanote/controller/note/NoteController.m | 2 +- Leanote/controller/note/NoteSettingsTableViewController.m | 2 +- Leanote/controller/note/NoteViewController.m | 2 +- Leanote/controller/tag/TagController.m | 2 +- Leanote/service/NoteService.m | 2 +- Leanote/view/LeaImageSliderViewController.m | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Leanote/controller/auth/LoginViewController.m b/Leanote/controller/auth/LoginViewController.m index 3d3400c..93593d4 100755 --- a/Leanote/controller/auth/LoginViewController.m +++ b/Leanote/controller/auth/LoginViewController.m @@ -42,7 +42,7 @@ static CGPoint const LoginOnePasswordPadding = {9.0, 0.0f}; static NSInteger const LoginVerificationCodeNumberOfLines = 2; -@interface LoginViewController () +@interface LoginViewController () @property (nonatomic, assign) BOOL isFromAddAccount; diff --git a/Leanote/controller/note/NoteController.m b/Leanote/controller/note/NoteController.m index 636ea28..7215436 100755 --- a/Leanote/controller/note/NoteController.m +++ b/Leanote/controller/note/NoteController.m @@ -23,7 +23,7 @@ #import -@interface NoteController () +@interface NoteController () @property (strong, nonatomic) NSIndexPath *indexPathToBeDeleted; @property (strong, nonatomic) NSFetchedResultsController *searchedResultsController; diff --git a/Leanote/controller/note/NoteSettingsTableViewController.m b/Leanote/controller/note/NoteSettingsTableViewController.m index 184621d..b1186da 100644 --- a/Leanote/controller/note/NoteSettingsTableViewController.m +++ b/Leanote/controller/note/NoteSettingsTableViewController.m @@ -43,7 +43,7 @@ typedef enum { } PostSettingsRow; -@interface NoteSettingsTableViewController () +@interface NoteSettingsTableViewController () @property (nonatomic, assign) BOOL preIsBlog; diff --git a/Leanote/controller/note/NoteViewController.m b/Leanote/controller/note/NoteViewController.m index 58a18e7..ce60bc1 100644 --- a/Leanote/controller/note/NoteViewController.m +++ b/Leanote/controller/note/NoteViewController.m @@ -64,7 +64,7 @@ static NSDictionary *EnabledButtonBarStyle; static NSInteger const MaximumNumberOfPictures = 10; -@interface NoteViewController () +@interface NoteViewController () @property(nonatomic, strong) NSMutableDictionary *mediaAdded; @property(nonatomic, strong) NSString *selectedMediaID; diff --git a/Leanote/controller/tag/TagController.m b/Leanote/controller/tag/TagController.m index 2abf782..d3ec089 100755 --- a/Leanote/controller/tag/TagController.m +++ b/Leanote/controller/tag/TagController.m @@ -17,7 +17,7 @@ #import "Leas.h" #import "NoteController.h" -@interface TagController () +@interface TagController () // 从setting过来要用 @property (nonatomic, strong) Note *note; diff --git a/Leanote/service/NoteService.m b/Leanote/service/NoteService.m index f8986c5..57831e4 100644 --- a/Leanote/service/NoteService.m +++ b/Leanote/service/NoteService.m @@ -23,7 +23,7 @@ // 把关于数据库操作的抽出来放到这里 - (NSFetchedResultsController *) fetchedResultsControllerWithPredicate:(NSString *)predicateStr - withController:(UIViewController *)controller + withController:(UIViewController *)controller notebook:(Notebook *)notebook tag:(Tag *)tag isBlog:(BOOL)isBlog diff --git a/Leanote/view/LeaImageSliderViewController.m b/Leanote/view/LeaImageSliderViewController.m index 59fb091..c2ea98d 100644 --- a/Leanote/view/LeaImageSliderViewController.m +++ b/Leanote/view/LeaImageSliderViewController.m @@ -13,7 +13,7 @@ #import "Common.h" -@interface LeaImageSliderViewController () +@interface LeaImageSliderViewController () { UILabel *_label; } From c00a0e98243aa0eb2bbc4f0288b948100921dc7b Mon Sep 17 00:00:00 2001 From: Wongzigii Date: Sat, 22 Aug 2015 12:18:13 +0800 Subject: [PATCH 2/5] Remove BOOL pointer type --- Leanote/controller/notebook/AddNotebookViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Leanote/controller/notebook/AddNotebookViewController.m b/Leanote/controller/notebook/AddNotebookViewController.m index 48051ed..4d0a5b8 100644 --- a/Leanote/controller/notebook/AddNotebookViewController.m +++ b/Leanote/controller/notebook/AddNotebookViewController.m @@ -47,7 +47,7 @@ typedef enum { @property UIBarButtonItem *doneButton; @property UIBarButtonItem *cancelButton; -@property (assign) BOOL *textFieldDidHaveFocusBeforeOrientationChange; +@property (assign) BOOL textFieldDidHaveFocusBeforeOrientationChange; @end From e99cb623d0e7b332bd8e7918ae144a1dc79451d3 Mon Sep 17 00:00:00 2001 From: Wongzigii Date: Sat, 22 Aug 2015 12:23:59 +0800 Subject: [PATCH 3/5] Handle all enumeration values in switch --- Leanote/controller/note/NoteController.m | 5 ++++- Leanote/controller/notebook/NotebookController.m | 3 +++ Leanote/controller/tag/TagController.m | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Leanote/controller/note/NoteController.m b/Leanote/controller/note/NoteController.m index 7215436..e14fd9a 100755 --- a/Leanote/controller/note/NoteController.m +++ b/Leanote/controller/note/NoteController.m @@ -724,7 +724,10 @@ case NSFetchedResultsChangeDelete: [tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade]; - break; + break; + case NSFetchedResultsChangeUpdate: + case NSFetchedResultsChangeMove: + break; } } diff --git a/Leanote/controller/notebook/NotebookController.m b/Leanote/controller/notebook/NotebookController.m index 8203226..b34f38d 100755 --- a/Leanote/controller/notebook/NotebookController.m +++ b/Leanote/controller/notebook/NotebookController.m @@ -693,6 +693,9 @@ [tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade]; break; + case NSFetchedResultsChangeMove: + case NSFetchedResultsChangeUpdate: + break; } } diff --git a/Leanote/controller/tag/TagController.m b/Leanote/controller/tag/TagController.m index d3ec089..e0cefde 100755 --- a/Leanote/controller/tag/TagController.m +++ b/Leanote/controller/tag/TagController.m @@ -573,6 +573,9 @@ [tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade]; break; + case NSFetchedResultsChangeMove: + case NSFetchedResultsChangeUpdate: + break; } } From 46b741e26cd8e8c2099a2f61cfd3cdea7912e8bf Mon Sep 17 00:00:00 2001 From: Wongzigii Date: Sat, 22 Aug 2015 12:24:47 +0800 Subject: [PATCH 4/5] Convert int to NSUInteger --- Leanote/controller/note/NoteViewController.m | 2 +- Leanote/service/SyncService.m | 12 ++++++------ Leanote/util/LeaURLRequest.m | 2 +- Leanote/view/LeaImageSliderViewController.h | 2 +- Leanote/view/LeaImageSliderViewController.m | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Leanote/controller/note/NoteViewController.m b/Leanote/controller/note/NoteViewController.m index ce60bc1..5368932 100644 --- a/Leanote/controller/note/NoteViewController.m +++ b/Leanote/controller/note/NoteViewController.m @@ -539,7 +539,7 @@ BOOL hiddenBar = NO; } // 得到当前的url - int count = [realUrls count]; + NSUInteger count = [realUrls count]; if(count < 1) { return; } diff --git a/Leanote/service/SyncService.m b/Leanote/service/SyncService.m index 86bf306..035d8f5 100644 --- a/Leanote/service/SyncService.m +++ b/Leanote/service/SyncService.m @@ -92,7 +92,7 @@ BOOL inSyncing = NO; // 同步笔记本 - (void) syncNotebook:(NSNumber *)afterUsn callback:(void (^)(BOOL))callback { - NSNumber *maxEntry = [NSNumber numberWithInt:maxEntryInt]; + NSNumber *maxEntry = [NSNumber numberWithUnsignedInteger:maxEntryInt]; [ApiService getSyncNotebooks:afterUsn maxEntry:maxEntry success:^(NSArray * notebookObjs) { if(self.canceled) { return; @@ -100,7 +100,7 @@ BOOL inSyncing = NO; [self syncNotebookToLocal:notebookObjs]; // 如果一样, 表示很可能还有笔记本, 得到最大的usn, 递归调用之 - int count = [notebookObjs count]; + NSUInteger count = [notebookObjs count]; if (count == maxEntryInt) { NSNumber *maxUsn = notebookObjs[count-1][@"Usn"]; [self syncNotebook:maxUsn callback:callback]; @@ -186,7 +186,7 @@ BOOL inSyncing = NO; // 同步笔记 - (void) syncNote:(NSNumber *)afterUsn callback:(void (^)(BOOL))callback { - NSNumber *maxEntry = [NSNumber numberWithInt:maxEntryInt]; + NSNumber *maxEntry = [NSNumber numberWithUnsignedInteger:maxEntryInt]; [ApiService getSyncNotes:afterUsn maxEntry:maxEntry success:^(NSArray * noteObjs) { if(self.canceled) { return; @@ -194,7 +194,7 @@ BOOL inSyncing = NO; [self syncNoteToLocal:noteObjs]; // 如果一样, 表示很可能还有笔记本, 得到最大的usn, 递归调用之 - int count = [noteObjs count]; + NSUInteger count = [noteObjs count]; if (count == maxEntryInt) { NSNumber *maxUsn = noteObjs[count-1][@"Usn"]; [self syncNote:maxUsn callback:callback]; @@ -244,7 +244,7 @@ BOOL inSyncing = NO; // 同步标签 - (void) syncTag:(NSNumber *)afterUsn callback:(void (^)(BOOL))callback { - NSNumber *maxEntry = [NSNumber numberWithInt:maxEntryInt]; + NSNumber *maxEntry = [NSNumber numberWithUnsignedInteger:maxEntryInt]; [ApiService getSyncTags:afterUsn maxEntry:maxEntry success:^(NSArray * tagObjs) { if(self.canceled) { return; @@ -252,7 +252,7 @@ BOOL inSyncing = NO; [self syncTagToLocal:tagObjs]; // 如果一样, 表示很可能还有Tag, 得到最大的usn, 递归调用之 - int count = [tagObjs count]; + NSUInteger count = [tagObjs count]; if (count == maxEntryInt) { NSNumber *maxUsn = tagObjs[count-1][@"Usn"]; [self syncTag:maxUsn callback:callback]; diff --git a/Leanote/util/LeaURLRequest.m b/Leanote/util/LeaURLRequest.m index 00e3a36..6178a9e 100755 --- a/Leanote/util/LeaURLRequest.m +++ b/Leanote/util/LeaURLRequest.m @@ -39,7 +39,7 @@ request.HTTPBody = [requestBody dataUsingEncoding:NSUTF8StringEncoding]; // Auth Headers - [request setValue:[NSString stringWithFormat:@"%d", requestBody.length] forHTTPHeaderField:@"Content-Length"]; + [request setValue:[NSString stringWithFormat:@"%lu", requestBody.length] forHTTPHeaderField:@"Content-Length"]; [request addValue:@"*/*" forHTTPHeaderField:@"Accept"]; // Bearer Token diff --git a/Leanote/view/LeaImageSliderViewController.h b/Leanote/view/LeaImageSliderViewController.h index 8dce168..045fb9d 100644 --- a/Leanote/view/LeaImageSliderViewController.h +++ b/Leanote/view/LeaImageSliderViewController.h @@ -16,6 +16,6 @@ @property (strong, nonatomic) NSArray *urlArr; @property (strong, nonatomic) NSString *curUrl; -@property int curIndex; +@property NSUInteger curIndex; @end \ No newline at end of file diff --git a/Leanote/view/LeaImageSliderViewController.m b/Leanote/view/LeaImageSliderViewController.m index c2ea98d..4885584 100644 --- a/Leanote/view/LeaImageSliderViewController.m +++ b/Leanote/view/LeaImageSliderViewController.m @@ -20,7 +20,7 @@ @property (nonatomic, strong) UIButton *saveBtn; -@property int count; +@property NSUInteger count; @property (strong, nonatomic) NSMutableArray *views; @end @@ -222,7 +222,7 @@ } -(void)setIndexLabel { - _label.text = [NSString stringWithFormat:@"%i/%i", self.curIndex + 1, self.count]; + _label.text = [NSString stringWithFormat:@"%lu/%lu", self.curIndex + 1, self.count]; } @end From 1b0cc47e9657bfbaf6025bd42f34a2438c739e7c Mon Sep 17 00:00:00 2001 From: Wongzigii Date: Sat, 22 Aug 2015 12:25:19 +0800 Subject: [PATCH 5/5] Fix return value in AppDelegate --- Leanote/AppDelegate.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Leanote/AppDelegate.m b/Leanote/AppDelegate.m index c2a4e88..7f1c760 100755 --- a/Leanote/AppDelegate.m +++ b/Leanote/AppDelegate.m @@ -142,6 +142,7 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self customizeAppearance]; + return YES; } // 全局样式设置