Skip to content

Commit

Permalink
Added initializers on VTAcknowledgementsViewController with more su…
Browse files Browse the repository at this point in the history
…ccinct names

Added `initWithPath:` initializer on `VTAcknowledgementsViewController`
Added `initWithFileNamed:` convenience initializer on `VTAcknowledgementsViewController`
Deprecated `initWithAcknowledgementsPlistPath:` on `VTAcknowledgementsViewController`
Deprecated `initWithAcknowledgementsFileNamed:` on `VTAcknowledgementsViewController`
  • Loading branch information
vtourraine committed May 20, 2016
1 parent 474c966 commit 174a9dc
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,10 @@
## 1.1 (work in progress)

- Added tvOS support, by Alex Palman (@alexpalman)
- Added `initWithPath:` initializer on `VTAcknowledgementsViewController`
- Added `initWithFileNamed:` convenience initializer on `VTAcknowledgementsViewController`
- Deprecated `initWithAcknowledgementsPlistPath:` on `VTAcknowledgementsViewController` (use `initWithPath` instead)
- Deprecated `initWithAcknowledgementsFileNamed:` on `VTAcknowledgementsViewController` (use `initWithFileNamed` instead)


## 1.0 (10 May 2016)
Expand Down
26 changes: 24 additions & 2 deletions Classes/VTAcknowledgementsViewController.h
Expand Up @@ -77,14 +77,36 @@
*/
+ (nonnull NSString *)localizedTitle;

/**
**Deprecated** Initializes an acknowledgements view controller with the content of an acknowledgements file (by its path).
@param acknowledgementsPlistPath The path to the acknowledgements `.plist` file.
@return A newly created `VTAcknowledgementsViewController` instance.
@see -initWithPlistPath:
*/
- (nullable instancetype)initWithAcknowledgementsPlistPath:(nullable NSString *)acknowledgementsPlistPath DEPRECATED_MSG_ATTRIBUTE("use -initWithPath: method instead");

/**
Initializes an acknowledgements view controller with the content of an acknowledgements file (by its path).
@param acknowledgementsPlistPath The path to the acknowledgements `.plist` file.
@return A newly created `VTAcknowledgementsViewController` instance.
*/
- (nullable instancetype)initWithAcknowledgementsPlistPath:(nullable NSString *)acknowledgementsPlistPath;
- (nullable instancetype)initWithPath:(nullable NSString *)acknowledgementsPlistPath;

/**
**Deprecated** Initializes an acknowledgements view controller with the content of an acknowledgements file (by its name).
@param acknowledgementsFileName The file name for the acknowledgements `.plist` file from the main bundle.
@return A newly created `VTAcknowledgementsViewController` instance.
@see -initWithFileNamed:
*/
- (nullable instancetype)initWithAcknowledgementsFileNamed:(nullable NSString *)acknowledgementsFileName DEPRECATED_MSG_ATTRIBUTE("use -initWithFileNamed: method instead");

/**
Initializes an acknowledgements view controller with the content of an acknowledgements file (by its name).
Expand All @@ -93,6 +115,6 @@
@return A newly created `VTAcknowledgementsViewController` instance.
*/
- (nullable instancetype)initWithAcknowledgementsFileNamed:(nullable NSString *)acknowledgementsFileName;
- (nullable instancetype)initWithFileNamed:(nonnull NSString *)acknowledgementsFileName;

@end
16 changes: 13 additions & 3 deletions Classes/VTAcknowledgementsViewController.m
Expand Up @@ -82,7 +82,7 @@ + (instancetype)acknowledgementsViewController
return [[self.class alloc] initWithAcknowledgementsPlistPath:path];
}

- (instancetype)initWithAcknowledgementsPlistPath:(NSString *)acknowledgementsPlistPath
- (instancetype)initWithPath:(NSString *)acknowledgementsPlistPath
{
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
Expand All @@ -92,10 +92,20 @@ - (instancetype)initWithAcknowledgementsPlistPath:(NSString *)acknowledgementsPl
return self;
}

- (nullable instancetype)initWithAcknowledgementsFileNamed:(nullable NSString *)acknowledgementsFileName
- (instancetype)initWithAcknowledgementsPlistPath:(NSString *)acknowledgementsPlistPath
{
return [self initWithPath:acknowledgementsPlistPath];
}

- (nullable instancetype)initWithFileNamed:(nonnull NSString *)acknowledgementsFileName
{
NSString *path = [[NSBundle mainBundle] pathForResource:acknowledgementsFileName ofType:@"plist"];
return [self initWithAcknowledgementsPlistPath:path];
return [self initWithPath:path];
}

- (nullable instancetype)initWithAcknowledgementsFileNamed:(nullable NSString *)acknowledgementsFileName
{
return [self initWithFileNamed:acknowledgementsFileName];
}

- (void)awakeFromNib
Expand Down
11 changes: 11 additions & 0 deletions Tests/Tests/VTAcknowledgementsViewControllerTests.m
Expand Up @@ -39,6 +39,17 @@ - (void)testGeneralInitialization {
XCTAssertNotNil(viewController.title);
}

- (void)testInitializationWithFileName {
VTAcknowledgementsViewController *viewController = [[VTAcknowledgementsViewController alloc] initWithFileNamed:@"Pods-acknowledgements"];
XCTAssertNotNil(viewController.acknowledgements);
}

- (void)testInitializationWithFilePath {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Pods-acknowledgements" ofType:@"plist"];
VTAcknowledgementsViewController *viewController = [[VTAcknowledgementsViewController alloc] initWithPath:path];
XCTAssertNotNil(viewController.acknowledgements);
}

- (void)testLoadAcknowledgementsWithDefaultFileName {
VTAcknowledgementsViewController *viewController = [VTAcknowledgementsViewController acknowledgementsViewController];
XCTAssertEqual(viewController.acknowledgements.count, 1,
Expand Down
2 changes: 1 addition & 1 deletion Tests/VTAck App/Classes/ViewController.m
Expand Up @@ -28,7 +28,7 @@
@implementation ViewController

- (IBAction)pushAckViewController:(id)sender {
VTAcknowledgementsViewController *viewController = [[VTAcknowledgementsViewController alloc] initWithAcknowledgementsFileNamed:@"Pods-VTAck App-acknowledgements"];
VTAcknowledgementsViewController *viewController = [[VTAcknowledgementsViewController alloc] initWithFileNamed:@"Pods-VTAck App-acknowledgements"];
[self.navigationController pushViewController:viewController animated:YES];
}

Expand Down

0 comments on commit 174a9dc

Please sign in to comment.