diff --git a/JobTracker/JTPageLoadOperation.m b/JobTracker/JTPageLoadOperation.m
index af368a0..cddfbd0 100644
--- a/JobTracker/JTPageLoadOperation.m
+++ b/JobTracker/JTPageLoadOperation.m
@@ -30,9 +30,9 @@ - (void)main {
NSLog(@"Error loading document: %@", error);
}
- [[[JTState alloc] init] performSelectorOnMainThread:@selector(pageLoaded:)
- withObject:document
- waitUntilDone:YES];
+ [[JTState sharedInstance] performSelectorOnMainThread:@selector(pageLoaded:)
+ withObject:document
+ waitUntilDone:YES];
}
@end
diff --git a/JobTracker/JTState.h b/JobTracker/JTState.h
index 95cead4..fc2b91c 100644
--- a/JobTracker/JTState.h
+++ b/JobTracker/JTState.h
@@ -1,5 +1,5 @@
//
-// JTParser.h
+// JTState.h
// JobTracker
//
// Created by Brad Greenlee on 11/6/12.
@@ -21,7 +21,8 @@
@property(nonatomic, retain) NSArray *usernames;
@property(nonatomic, retain) id delegate;
-- (id)initWithURL:(NSURL *)url withUsernames:(NSString *)usernames;
++ (id)sharedInstance;
+- (void)setUsernameString:(NSString *)usernames;
- (void)pageLoaded:(NSXMLDocument *)document;
- (void)refresh;
- (void)parse:(NSXMLDocument *)document;
diff --git a/JobTracker/JTState.m b/JobTracker/JTState.m
index 564435a..b91490a 100644
--- a/JobTracker/JTState.m
+++ b/JobTracker/JTState.m
@@ -1,5 +1,5 @@
//
-// JTParser.m
+// JTState.m
// JobTracker
//
// Created by Brad Greenlee on 11/6/12.
@@ -14,28 +14,33 @@ @implementation JTState
@synthesize clusterSummary, jobs, url, usernames, delegate;
-- (id)init {
- if (shared) {
- return shared;
++ (id)sharedInstance {
+ return shared;
+}
+
++ (void)initialize {
+ static BOOL initialized = NO;
+ if (!initialized) {
+ initialized = YES;
+ shared = [[JTState alloc] init];
}
+}
+
+- (id)init {
if ((self = [super init])) {
clusterSummary = [[NSMutableDictionary alloc] init];
jobs = [[NSMutableDictionary alloc] init];
queue = [[NSOperationQueue alloc] init];
}
- shared = self;
return self;
}
-- (id)initWithURL:(NSURL *)_url withUsernames:(NSString *)_usernames{
- self = [self init];
- url = _url;
+- (void)setUsernameString:(NSString *)_usernames{
if (_usernames == nil || [_usernames isEqualToString:@""]) {
usernames = nil;
} else {
usernames = [_usernames componentsSeparatedByString:@","];
}
- return self;
}
- (void)pageLoaded:(NSXMLDocument *)document {
diff --git a/JobTracker/JTStatusMenu.m b/JobTracker/JTStatusMenu.m
index b0b039f..4ab9998 100644
--- a/JobTracker/JTStatusMenu.m
+++ b/JobTracker/JTStatusMenu.m
@@ -34,8 +34,9 @@ - (void)awakeFromNib {
[self loadPreferences];
if ([self isConfigured]) {
- jtState = [[JTState alloc] initWithURL:[NSURL URLWithString:[jobTrackerURL stringByAppendingString:@"/jobtracker.jsp"]]
- withUsernames:usernames];
+ jtState = [JTState sharedInstance];
+ jtState.url = [NSURL URLWithString:[jobTrackerURL stringByAppendingString:@"/jobtracker.jsp"]];
+ [jtState setUsernameString:usernames];
jtState.delegate = self;
[self refresh:nil];
[self startTimer];
@@ -212,8 +213,9 @@ - (IBAction)openInBrowser:(id)sender {
- (void)preferencesUpdated {
[self loadPreferences];
if ([self isConfigured]) {
- jtState = [[JTState alloc] initWithURL:[NSURL URLWithString:[jobTrackerURL stringByAppendingString:@"/jobtracker.jsp"]]
- withUsernames:usernames];
+ jtState = [JTState sharedInstance];
+ jtState.url = [NSURL URLWithString:[jobTrackerURL stringByAppendingString:@"/jobtracker.jsp"]];
+ [jtState setUsernameString:usernames];
jtState.delegate = self;
[self refresh:nil];
[self startTimer];
diff --git a/JobTracker/JobTracker-Info.plist b/JobTracker/JobTracker-Info.plist
index 18cdd6e..c0d966e 100644
--- a/JobTracker/JobTracker-Info.plist
+++ b/JobTracker/JobTracker-Info.plist
@@ -21,7 +21,7 @@
CFBundleSignature
????
CFBundleVersion
- 1.0.3
+ 1.0.4
LSApplicationCategoryType
public.app-category.developer-tools
LSMinimumSystemVersion
diff --git a/JobTrackerTests/JTStateTests.m b/JobTrackerTests/JTStateTests.m
index 45938a6..8d586da 100644
--- a/JobTrackerTests/JTStateTests.m
+++ b/JobTrackerTests/JTStateTests.m
@@ -18,7 +18,8 @@ - (void)setUp {
NSXMLDocument *document = [[NSXMLDocument alloc] initWithContentsOfURL:fileUrl
options:NSXMLDocumentTidyHTML
error:nil];
- jtState = [[JTState alloc] initWithURL:fileUrl withUsernames:nil];
+ jtState = [JTState sharedInstance];
+ jtState.url = fileUrl;
[jtState pageLoaded:document];
}