diff --git a/Tools/XcodeCapp/FSEventCallback.m b/Tools/XcodeCapp/FSEventCallback.m index c4af80093..9df1fd56a 100644 --- a/Tools/XcodeCapp/FSEventCallback.m +++ b/Tools/XcodeCapp/FSEventCallback.m @@ -138,4 +138,6 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, } } } + + [xcc updateUserDefaultsWithLastEventId]; } diff --git a/Tools/XcodeCapp/TNXCodeCapp.h b/Tools/XcodeCapp/TNXCodeCapp.h index 937132502..51c507de3 100644 --- a/Tools/XcodeCapp/TNXCodeCapp.h +++ b/Tools/XcodeCapp/TNXCodeCapp.h @@ -80,6 +80,8 @@ extern NSString * const XCCListeningStartNotification; - (void)initializeEventStreamWithPath:(NSString*)aPath; - (void)stopEventStream; - (void)updateLastEventId:(uint64_t)eventId; +- (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 ffe2d1cab..e6d6e9af7 100644 --- a/Tools/XcodeCapp/TNXCodeCapp.m +++ b/Tools/XcodeCapp/TNXCodeCapp.m @@ -195,13 +195,8 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification */ - (void)clear { - if (lastEventId && [lastEventId longLongValue] != 0) - { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - [defaults setObject:lastEventId forKey:@"lastEventId"]; - [defaults synchronize]; - } - + [self updateUserDefaultsWithLastEventId]; + [self synchronizeUserDefaultsWithDisk]; currentProjectURL = nil; currentProjectName = nil; [ignoredFilePaths removeAllObjects]; @@ -259,6 +254,25 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification lastEventId = [NSNumber numberWithUnsignedLongLong:eventId]; } +/*! + Updates the user defaults with the last recorded event Id. + */ +- (void)updateUserDefaultsWithLastEventId +{ + if (lastEventId && [lastEventId longLongValue] != 0) + { + [[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