Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

started model and moved githubusername to Config model

  • Loading branch information...
commit 3bb6717cf0c99cb3979714d0e69a5da61f64c253 1 parent fa3d4a0
@sschroed authored
View
20 Classes/Config.h
@@ -0,0 +1,20 @@
+//
+// Config.h
+// git-phone
+//
+// Created by Sam Schroeder on 1/16/09.
+// Copyright 2009 Proton Microsystems, LLC. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface Config : NSObject {
+ NSString *gitHubUserName;
+}
+
+@property (copy) NSString *gitHubUserName;
+
++ (Config *)instance;
+
+@end
View
34 Classes/Config.m
@@ -0,0 +1,34 @@
+//
+// Config.m
+// git-phone
+//
+// Created by Sam Schroeder on 1/16/09.
+// Copyright 2009 Proton Microsystems, LLC. All rights reserved.
+//
+
+#import "Config.h"
+
+
+@implementation Config
+
+@synthesize gitHubUserName;
+
+// Make model a singleton
++ (Config *)instance
+{
+ static Config *gInstance = NULL;
+
+ @synchronized(self)
+ {
+ if (gInstance == NULL)
+ gInstance = [[self alloc] init];
+ }
+ return(gInstance);
+}
+
+- (void) dealloc {
+ [gitHubUserName release];
+ [super dealloc];
+}
+
+@end
View
9 Classes/Models.h
@@ -0,0 +1,9 @@
+//
+// Models.h
+// git-phone
+//
+// Created by Sam Schroeder on 1/16/09.
+// Copyright 2009 Proton Microsystems, LLC. All rights reserved.
+//
+
+#import "Config.h"
View
2  Classes/RootViewController.h
@@ -9,8 +9,6 @@
#import <UIKit/UIKit.h>
@interface RootViewController : UITableViewController {
-
- NSString *gitHubUserName;
}
@end
View
10 Classes/RootViewController.m
@@ -12,17 +12,10 @@
@implementation RootViewController
-- (void) loadPrefs {
- // read user prefs
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- gitHubUserName = [defaults stringForKey:@"GitHubUserName"];
-}
+
- (void)viewDidLoad {
[super viewDidLoad];
- [self loadPrefs];
-
- DevLog2(@"username: %@", gitHubUserName);
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
@@ -140,7 +133,6 @@ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)
*/
- (void)dealloc {
- [gitHubUserName release];
[super dealloc];
}
View
15 Classes/git_phoneAppDelegate.m
@@ -8,6 +8,7 @@
#import "git_phoneAppDelegate.h"
#import "RootViewController.h"
+#import "Models.h"
@implementation git_phoneAppDelegate
@@ -15,12 +16,26 @@ @implementation git_phoneAppDelegate
@synthesize window;
@synthesize navigationController;
+- (void) loadPreferencess {
+ // read user prefs
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ [[Config instance] setGitHubUserName:[defaults stringForKey:@"GitHubUserName"]];
+
+ DevLog2(@"username: %@", [[Config instance] gitHubUserName]);
+
+ // Check if username is set
+ //if (gitHubUserName == NULL) {
+
+ //}
+}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
+
+ [self loadPreferencess];
}
View
24 git-phone.xcodeproj/project.pbxproj
@@ -13,6 +13,7 @@
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
22FA50040F212ED300709123 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 22FA50030F212ED300709123 /* Settings.bundle */; };
22FA502E0F21374300709123 /* octocat.png in Resources */ = {isa = PBXBuildFile; fileRef = 22FA502D0F21374300709123 /* octocat.png */; };
+ 22FA50CE0F21463D00709123 /* Config.m in Sources */ = {isa = PBXBuildFile; fileRef = 22FA50CD0F21463D00709123 /* Config.m */; };
2892E4100DC94CBA00A64D0F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */; };
2899E5600DE3E45000AC0155 /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E55F0DE3E45000AC0155 /* RootViewController.xib */; };
28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD735F0D9D9599002E5188 /* MainWindow.xib */; };
@@ -27,6 +28,9 @@
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
22FA50030F212ED300709123 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
22FA502D0F21374300709123 /* octocat.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = octocat.png; path = images/octocat.png; sourceTree = "<group>"; };
+ 22FA50CC0F21463D00709123 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = Classes/Config.h; sourceTree = "<group>"; };
+ 22FA50CD0F21463D00709123 /* Config.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Config.m; path = Classes/Config.m; sourceTree = "<group>"; };
+ 22FA50DB0F2147DC00709123 /* Models.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Models.h; path = Classes/Models.h; sourceTree = "<group>"; };
2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
2899E55F0DE3E45000AC0155 /* RootViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = "<group>"; };
28A0AAE50D9B0CCF005BE974 /* git_phone_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = git_phone_Prefix.pch; sourceTree = "<group>"; };
@@ -78,9 +82,28 @@
name = Images;
sourceTree = "<group>";
};
+ 22FA50C60F2144DF00709123 /* Models */ = {
+ isa = PBXGroup;
+ children = (
+ 22FA50DB0F2147DC00709123 /* Models.h */,
+ 22FA50CC0F21463D00709123 /* Config.h */,
+ 22FA50CD0F21463D00709123 /* Config.m */,
+ );
+ name = Models;
+ sourceTree = "<group>";
+ };
+ 22FA50C70F2144F800709123 /* Networking */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ name = Networking;
+ sourceTree = "<group>";
+ };
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
+ 22FA50C70F2144F800709123 /* Networking */,
+ 22FA50C60F2144DF00709123 /* Models */,
080E96DDFE201D6D7F000001 /* Classes */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
29B97317FDCFA39411CA2CEA /* Resources */,
@@ -187,6 +210,7 @@
1D60589B0D05DD56006BFB54 /* main.m in Sources */,
1D3623260D0F684500981E51 /* git_phoneAppDelegate.m in Sources */,
28C286E10D94DF7D0034E888 /* RootViewController.m in Sources */,
+ 22FA50CE0F21463D00709123 /* Config.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Please sign in to comment.
Something went wrong with that request. Please try again.