3838#import " MDACTextCredit.h"
3939#import " MDACImageCredit.h"
4040#import " MDACIconCredit.h"
41+ #import " MDACWebViewController.h"
4142
4243#pragma mark Constants
4344
5253
5354@implementation MDAboutController
5455
55- @synthesize showsTitleBar, titleBar, backgroundColor, hasSimpleBackground;
56+ @synthesize showsTitleBar, titleBar, backgroundColor, hasSimpleBackground, credits ;
5657
5758- (id )initWithNibName : (NSString *)nibNameOrNil bundle : (NSBundle *)nibBundleOrNil
5859{
@@ -71,14 +72,17 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
7172 // self.navigationItem.title = [NSString stringWithFormat:@"About %@", appName];
7273 self.navigationItem .title = @" About" ;
7374
74- if ([[[NSBundle mainBundle ] infoDictionary ] objectForKey: @" CFBundleShortVersionString" ] && [[[NSBundle mainBundle ] infoDictionary ] objectForKey: @" CFBundleVersion" ]) {
75+ NSString *bundleShortVersionString = [[[NSBundle mainBundle ] infoDictionary ] objectForKey: @" CFBundleShortVersionString" ];
76+ NSString *bundleVersionString = [[[NSBundle mainBundle ] infoDictionary ] objectForKey: @" CFBundleVersion" ];
77+
78+ if (bundleShortVersionString && bundleVersionString) {
7579 versionString = [NSString stringWithFormat: @" Version %@ (%@ )" ,
76- [[[ NSBundle mainBundle ] infoDictionary ] objectForKey: @" CFBundleShortVersionString " ] ,
77- [[[ NSBundle mainBundle ] infoDictionary ] objectForKey: @" CFBundleVersion " ] ];
78- } else if ([[[ NSBundle mainBundle ] infoDictionary ] objectForKey: @" CFBundleShortVersionString " ] ) {
79- versionString = [[[ NSBundle mainBundle ] infoDictionary ] objectForKey :@" CFBundleShortVersionString " ];
80- } else if ([[[ NSBundle mainBundle ] infoDictionary ] objectForKey: @" CFBundleVersion " ] ) {
81- versionString = [[[ NSBundle mainBundle ] infoDictionary ] objectForKey :@" CFBundleVersion " ];
80+ bundleShortVersionString ,
81+ bundleVersionString ];
82+ } else if (bundleShortVersionString ) {
83+ versionString = [NSString stringWithFormat :@" Version %@ " , bundleShortVersionString ];
84+ } else if (bundleVersionString ) {
85+ versionString = [NSString stringWithFormat :@" Version %@ " , bundleVersionString ];
8286 }
8387
8488 UIImage *icon = nil ;
@@ -124,7 +128,6 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
124128
125129 if (icon) {
126130 UIImage *maskImage = [UIImage imageNamed: @" MDACIconMask.png" ];
127- // icon = maskImage;
128131 icon = [icon maskedImageWithMask: maskImage];
129132 }
130133
@@ -149,8 +152,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
149152 [creditsFile release ];
150153 }
151154
152- // TOFIX: Do we need this? People might not want to have this in their app, but we could find another way of adding credits? Perhaps
153- // as a Credit item in the section table?
155+ // To remove (:sadface:) the following credit, call [aboutController removeLastCredit]; after initializing your controller.
154156
155157 [credits addObject: [MDACTextCredit textCreditWithText: @" About screen powered by MDAboutViewController, available free on GitHub!"
156158 font: [UIFont boldSystemFontOfSize: 11 ]
@@ -192,7 +194,7 @@ - (void)didReceiveMemoryWarning
192194
193195
194196
195- #pragma mark View lifecycle
197+ #pragma mark - View lifecycle
196198
197199- (void )generateCachedCells
198200{
@@ -564,7 +566,7 @@ - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath
564566 } else {
565567 NSURL *url = [(MDACListCredit *)credit itemAtIndex: index].link ;
566568
567- MDWebViewController *linkViewController = [[MDWebViewController alloc ] initWithURL: url];
569+ MDACWebViewController *linkViewController = [[MDACWebViewController alloc ] initWithURL: url];
568570 [[self navigationController ] pushViewController: linkViewController animated: YES ];
569571 [linkViewController release ];
570572 }
@@ -577,7 +579,7 @@ - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath
577579 } else {
578580 NSURL *url =[(MDACTextCredit *)credit link ];
579581
580- MDWebViewController *linkViewController = [[MDWebViewController alloc ] initWithURL: url];
582+ MDACWebViewController *linkViewController = [[MDACWebViewController alloc ] initWithURL: url];
581583 [[self navigationController ] pushViewController: linkViewController animated: YES ];
582584 [linkViewController release ];
583585 }
@@ -721,5 +723,72 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
721723 return YES ;
722724}
723725
726+ #pragma mark - Manipulating Credits
727+
728+ - (void )addCredit : (MDACCredit *)aCredit
729+ {
730+ [credits addObject: aCredit];
731+
732+ [cachedCellCredits release ];
733+ cachedCellCredits = nil ;
734+
735+ [tableView reloadData ];
736+ }
737+
738+ - (void )insertCredit : (MDACCredit *)aCredit atIndex : (NSUInteger )index
739+ {
740+ [credits insertObject: aCredit atIndex: index];
741+
742+ [cachedCellCredits release ];
743+ cachedCellCredits = nil ;
744+
745+ [tableView reloadData ];
746+ }
747+
748+ - (void )replaceCreditAtIndex : (NSUInteger )index withCredit : (MDACCredit *)aCredit
749+ {
750+ [credits replaceObjectAtIndex: index withObject: aCredit];
751+
752+ [cachedCellCredits release ];
753+ cachedCellCredits = nil ;
754+
755+ [tableView reloadData ];
756+ }
757+
758+ - (void )removeLastCredit
759+ {
760+ [credits removeLastObject ];
761+
762+ [cachedCellCredits release ];
763+ cachedCellCredits = nil ;
764+
765+ [tableView reloadData ];
766+ }
767+
768+ - (void )removeCredit : (MDACCredit *)aCredit
769+ {
770+ [credits removeObject: aCredit];
771+
772+ [cachedCellCredits release ];
773+ cachedCellCredits = nil ;
774+
775+ [tableView reloadData ];
776+ }
777+
778+ - (void )removeCreditAtIndex : (NSUInteger )index
779+ {
780+ [credits removeObjectAtIndex: index];
781+
782+ [cachedCellCredits release ];
783+ cachedCellCredits = nil ;
784+
785+ [tableView reloadData ];
786+ }
787+
788+ - (NSUInteger )creditCount
789+ {
790+ return [credits count ];
791+ }
792+
724793@end
725794
0 commit comments