Loading Great iPhone Development Source Code/.gitignore 0 → 100755 +12 −0 Changes for Great iPhone Development Source Code/.gitignore: 12 added lines, 0 removed lines. Original line number Diff line number Diff line build/* .DS_Store *.swp *~.nib build/ *.pbxuser *.perspective *.perspectivev3 *.mode1v3 *.mode2v3 No newline at end of file Great iPhone Development Source Code/Classes/FlipsideViewController.h 0 → 100755 +28 −0 Changes for Great iPhone Development Source Code/Classes/FlipsideViewController.h: 28 added lines, 0 removed lines. Original line number Diff line number Diff line // // FlipsideViewController.h // GreatTeleprompter // // Created by Scott Means on 4/4/10. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import <UIKit/UIKit.h> @protocol FlipsideViewControllerDelegate; @interface FlipsideViewController : UIViewController { id <FlipsideViewControllerDelegate> delegate; IBOutlet UITextView *theSpeech; } @property (nonatomic, assign) id <FlipsideViewControllerDelegate> delegate; - (IBAction)done; @end @protocol FlipsideViewControllerDelegate - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller; @end Great iPhone Development Source Code/Classes/FlipsideViewController.m 0 → 100755 +53 −0 Changes for Great iPhone Development Source Code/Classes/FlipsideViewController.m: 53 added lines, 0 removed lines. Original line number Diff line number Diff line // // FlipsideViewController.m // GreatTeleprompter // // Created by Scott Means on 4/4/10. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "GreatTeleprompterAppDelegate.h" #import "FlipsideViewController.h" @implementation FlipsideViewController @synthesize delegate; - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor]; theSpeech.text = theAppDelegate.currentSpeech; } - (IBAction)done { [self.delegate flipsideViewControllerDidFinish:self]; theAppDelegate.currentSpeech = theSpeech.text; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (void)dealloc { [super dealloc]; } @end Great iPhone Development Source Code/Classes/GreatTeleprompterAppDelegate.h 0 → 100755 +32 −0 Changes for Great iPhone Development Source Code/Classes/GreatTeleprompterAppDelegate.h: 32 added lines, 0 removed lines. Original line number Diff line number Diff line // // GreatTeleprompterAppDelegate.h // GreatTeleprompter // // Created by Scott Means on 4/4/10. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import <UIKit/UIKit.h> @class MainViewController; @interface GreatTeleprompterAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MainViewController *mainViewController; int currentSpeechIndex; NSMutableArray *speeches; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) MainViewController *mainViewController; @property (nonatomic, assign) int currentSpeechIndex; @property (nonatomic, retain) NSString *currentSpeech; @property (nonatomic, readonly) NSArray *speeches; @property (nonatomic, readonly) NSString *docDir; - (void)deleteCurrentSpeech; @end #define theAppDelegate ((GreatTeleprompterAppDelegate *)[UIApplication sharedApplication].delegate) #define CURRENTSPEECHINDEX_KEY @"CurrentSpeechIndex" No newline at end of file Great iPhone Development Source Code/Classes/GreatTeleprompterAppDelegate.m 0 → 100755 +102 −0 Changes for Great iPhone Development Source Code/Classes/GreatTeleprompterAppDelegate.m: 102 added lines, 0 removed lines. Original line number Diff line number Diff line // // GreatTeleprompterAppDelegate.m // GreatTeleprompter // // Created by Scott Means on 4/4/10. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "GreatTeleprompterAppDelegate.h" #import "MainViewController.h" @implementation GreatTeleprompterAppDelegate @synthesize window; @synthesize mainViewController; @synthesize currentSpeechIndex; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { speeches = [[NSMutableArray alloc] initWithContentsOfFile:[self.docDir stringByAppendingPathComponent:@"speeches"]]; if (!speeches) { speeches = [[NSMutableArray alloc] init]; } if ([speeches count] <= 0) { NSString *path = [[NSBundle mainBundle] pathForResource:@"DefaultSpeech" ofType:@"txt"]; [speeches addObject:[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]]; } else { currentSpeechIndex = [[NSUserDefaults standardUserDefaults] integerForKey:CURRENTSPEECHINDEX_KEY]; } MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; self.mainViewController = aController; [aController release]; mainViewController.view.frame = [UIScreen mainScreen].applicationFrame; [window addSubview:[mainViewController view]]; [window makeKeyAndVisible]; return YES; } - (NSString *)currentSpeech { if (currentSpeechIndex >= 0 && currentSpeechIndex < [speeches count]) { return [speeches objectAtIndex:currentSpeechIndex]; } else { return @""; } } - (void)setCurrentSpeech:(NSString *)newSpeech { if (currentSpeechIndex >= 0 && currentSpeechIndex < [speeches count]) { [speeches removeObjectAtIndex:currentSpeechIndex]; [speeches insertObject:newSpeech atIndex:currentSpeechIndex]; } else { [speeches addObject:newSpeech]; self.currentSpeechIndex = [speeches count] - 1; } [speeches writeToFile:[self.docDir stringByAppendingPathComponent:@"speeches"] atomically:YES]; } - (void)setCurrentSpeechIndex:(int)newIndex { currentSpeechIndex = newIndex; [[NSUserDefaults standardUserDefaults] setInteger:currentSpeechIndex forKey:CURRENTSPEECHINDEX_KEY]; } - (void)deleteCurrentSpeech { if (currentSpeechIndex < 0 || currentSpeechIndex >= [speeches count]) { return; } [speeches removeObjectAtIndex:currentSpeechIndex]; [speeches writeToFile:[self.docDir stringByAppendingPathComponent:@"speeches"] atomically:YES]; self.currentSpeechIndex = MIN(self.currentSpeechIndex, [speeches count]-1); } - (NSString *)docDir { return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; } - (NSArray *)speeches { return speeches; } - (void)dealloc { [speeches release]; [mainViewController release]; [window release]; [super dealloc]; } @end Loading
Great iPhone Development Source Code/.gitignore 0 → 100755 +12 −0 Changes for Great iPhone Development Source Code/.gitignore: 12 added lines, 0 removed lines. Original line number Diff line number Diff line build/* .DS_Store *.swp *~.nib build/ *.pbxuser *.perspective *.perspectivev3 *.mode1v3 *.mode2v3 No newline at end of file
Great iPhone Development Source Code/Classes/FlipsideViewController.h 0 → 100755 +28 −0 Changes for Great iPhone Development Source Code/Classes/FlipsideViewController.h: 28 added lines, 0 removed lines. Original line number Diff line number Diff line // // FlipsideViewController.h // GreatTeleprompter // // Created by Scott Means on 4/4/10. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import <UIKit/UIKit.h> @protocol FlipsideViewControllerDelegate; @interface FlipsideViewController : UIViewController { id <FlipsideViewControllerDelegate> delegate; IBOutlet UITextView *theSpeech; } @property (nonatomic, assign) id <FlipsideViewControllerDelegate> delegate; - (IBAction)done; @end @protocol FlipsideViewControllerDelegate - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller; @end
Great iPhone Development Source Code/Classes/FlipsideViewController.m 0 → 100755 +53 −0 Changes for Great iPhone Development Source Code/Classes/FlipsideViewController.m: 53 added lines, 0 removed lines. Original line number Diff line number Diff line // // FlipsideViewController.m // GreatTeleprompter // // Created by Scott Means on 4/4/10. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "GreatTeleprompterAppDelegate.h" #import "FlipsideViewController.h" @implementation FlipsideViewController @synthesize delegate; - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor]; theSpeech.text = theAppDelegate.currentSpeech; } - (IBAction)done { [self.delegate flipsideViewControllerDidFinish:self]; theAppDelegate.currentSpeech = theSpeech.text; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (void)dealloc { [super dealloc]; } @end
Great iPhone Development Source Code/Classes/GreatTeleprompterAppDelegate.h 0 → 100755 +32 −0 Changes for Great iPhone Development Source Code/Classes/GreatTeleprompterAppDelegate.h: 32 added lines, 0 removed lines. Original line number Diff line number Diff line // // GreatTeleprompterAppDelegate.h // GreatTeleprompter // // Created by Scott Means on 4/4/10. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import <UIKit/UIKit.h> @class MainViewController; @interface GreatTeleprompterAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MainViewController *mainViewController; int currentSpeechIndex; NSMutableArray *speeches; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) MainViewController *mainViewController; @property (nonatomic, assign) int currentSpeechIndex; @property (nonatomic, retain) NSString *currentSpeech; @property (nonatomic, readonly) NSArray *speeches; @property (nonatomic, readonly) NSString *docDir; - (void)deleteCurrentSpeech; @end #define theAppDelegate ((GreatTeleprompterAppDelegate *)[UIApplication sharedApplication].delegate) #define CURRENTSPEECHINDEX_KEY @"CurrentSpeechIndex" No newline at end of file
Great iPhone Development Source Code/Classes/GreatTeleprompterAppDelegate.m 0 → 100755 +102 −0 Changes for Great iPhone Development Source Code/Classes/GreatTeleprompterAppDelegate.m: 102 added lines, 0 removed lines. Original line number Diff line number Diff line // // GreatTeleprompterAppDelegate.m // GreatTeleprompter // // Created by Scott Means on 4/4/10. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "GreatTeleprompterAppDelegate.h" #import "MainViewController.h" @implementation GreatTeleprompterAppDelegate @synthesize window; @synthesize mainViewController; @synthesize currentSpeechIndex; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { speeches = [[NSMutableArray alloc] initWithContentsOfFile:[self.docDir stringByAppendingPathComponent:@"speeches"]]; if (!speeches) { speeches = [[NSMutableArray alloc] init]; } if ([speeches count] <= 0) { NSString *path = [[NSBundle mainBundle] pathForResource:@"DefaultSpeech" ofType:@"txt"]; [speeches addObject:[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]]; } else { currentSpeechIndex = [[NSUserDefaults standardUserDefaults] integerForKey:CURRENTSPEECHINDEX_KEY]; } MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; self.mainViewController = aController; [aController release]; mainViewController.view.frame = [UIScreen mainScreen].applicationFrame; [window addSubview:[mainViewController view]]; [window makeKeyAndVisible]; return YES; } - (NSString *)currentSpeech { if (currentSpeechIndex >= 0 && currentSpeechIndex < [speeches count]) { return [speeches objectAtIndex:currentSpeechIndex]; } else { return @""; } } - (void)setCurrentSpeech:(NSString *)newSpeech { if (currentSpeechIndex >= 0 && currentSpeechIndex < [speeches count]) { [speeches removeObjectAtIndex:currentSpeechIndex]; [speeches insertObject:newSpeech atIndex:currentSpeechIndex]; } else { [speeches addObject:newSpeech]; self.currentSpeechIndex = [speeches count] - 1; } [speeches writeToFile:[self.docDir stringByAppendingPathComponent:@"speeches"] atomically:YES]; } - (void)setCurrentSpeechIndex:(int)newIndex { currentSpeechIndex = newIndex; [[NSUserDefaults standardUserDefaults] setInteger:currentSpeechIndex forKey:CURRENTSPEECHINDEX_KEY]; } - (void)deleteCurrentSpeech { if (currentSpeechIndex < 0 || currentSpeechIndex >= [speeches count]) { return; } [speeches removeObjectAtIndex:currentSpeechIndex]; [speeches writeToFile:[self.docDir stringByAppendingPathComponent:@"speeches"] atomically:YES]; self.currentSpeechIndex = MIN(self.currentSpeechIndex, [speeches count]-1); } - (NSString *)docDir { return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; } - (NSArray *)speeches { return speeches; } - (void)dealloc { [speeches release]; [mainViewController release]; [window release]; [super dealloc]; } @end