From 1fd021770ed23b3be5220d66cd4ae97bb13212aa Mon Sep 17 00:00:00 2001 From: Malte Tancred Date: Thu, 14 Jun 2012 11:43:52 +0200 Subject: [PATCH] Split -synchronizeLastEventId in two methods. The first method (updateUserDefaultsWithLastEventId) just sets the default while the other (synchronizeUserDefaultsWithDisk) forces a synchronization with the disk. --- Tools/XcodeCapp/FSEventCallback.m | 2 +- Tools/XcodeCapp/TNXCodeCapp.h | 3 ++- Tools/XcodeCapp/TNXCodeCapp.m | 20 ++++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Tools/XcodeCapp/FSEventCallback.m b/Tools/XcodeCapp/FSEventCallback.m index f546a0b78..9df1fd56a 100644 --- a/Tools/XcodeCapp/FSEventCallback.m +++ b/Tools/XcodeCapp/FSEventCallback.m @@ -139,5 +139,5 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, } } - [xcc synchronizeLastEventId]; + [xcc updateUserDefaultsWithLastEventId]; } diff --git a/Tools/XcodeCapp/TNXCodeCapp.h b/Tools/XcodeCapp/TNXCodeCapp.h index 1606df375..51c507de3 100644 --- a/Tools/XcodeCapp/TNXCodeCapp.h +++ b/Tools/XcodeCapp/TNXCodeCapp.h @@ -80,7 +80,8 @@ extern NSString * const XCCListeningStartNotification; - (void)initializeEventStreamWithPath:(NSString*)aPath; - (void)stopEventStream; - (void)updateLastEventId:(uint64_t)eventId; -- (void)synchronizeLastEventId; +- (void)updateUserDefaultsWithLastEventId; +- (void)synchronizeUserDefaultsWithDisk; - (void)listenProjectAtPath:(NSString *)path; - (void)clear; - (void)start; diff --git a/Tools/XcodeCapp/TNXCodeCapp.m b/Tools/XcodeCapp/TNXCodeCapp.m index d7f28b60b..e6d6e9af7 100644 --- a/Tools/XcodeCapp/TNXCodeCapp.m +++ b/Tools/XcodeCapp/TNXCodeCapp.m @@ -195,7 +195,8 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification */ - (void)clear { - [self synchronizeLastEventId]; + [self updateUserDefaultsWithLastEventId]; + [self synchronizeUserDefaultsWithDisk]; currentProjectURL = nil; currentProjectName = nil; [ignoredFilePaths removeAllObjects]; @@ -254,17 +255,24 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification } /*! - Synchronizes the last recorded event ID with the user defaults. + Updates the user defaults with the last recorded event Id. */ -- (void)synchronizeLastEventId { +- (void)updateUserDefaultsWithLastEventId +{ if (lastEventId && [lastEventId longLongValue] != 0) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - [defaults setObject:lastEventId forKey:@"lastEventId"]; - [defaults synchronize]; + [[NSUserDefaults standardUserDefaults] setObject:lastEventId forKey:@"lastEventId"]; } } +/*! + Tells the standard user defaults to synchronize with disk. + */ +- (void)synchronizeUserDefaultsWithDisk +{ + [[NSUserDefaults standardUserDefaults] synchronize]; +} + /*! Run a NSTask with the given arguments @param arguments NSArray containing the NSTask arguments