Skip to content

Commit

Permalink
Minor updates #34
Browse files Browse the repository at this point in the history
  • Loading branch information
iTofu committed Apr 26, 2017
1 parent 9bb1b14 commit 2fdb8ed
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Demo/LCActionSheetDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ - (IBAction)showBlockActionSheet {
NSMutableIndexSet *set = [[NSMutableIndexSet alloc] init];
[set addIndex:1];
[set addIndex:2];
[actionSheet appendButtonsWithTitles:@[@"Hello", @"World"] atIndexes:set];
[actionSheet appendButtonsWithTitles:@[@"Hello", @"World"] atIndexSet:set];
});
}

Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ In me the tiger sniffs the rose.
NSMutableIndexSet *set = [[NSMutableIndexSet alloc] init];
[set addIndex:1];
[set addIndex:2];
[actionSheet appendButtonsWithTitles:@[@"Hello", @"World"] atIndexes:set];
[actionSheet appendButtonsWithTitles:@[@"Hello", @"World"] atIndexSet:set];
});

[actionSheet show];
Expand Down Expand Up @@ -283,37 +283,41 @@ In me the tiger sniffs the rose.

```objc
@interface LCActionSheet : UIView

// Append button at index with title.
- (void)appendButtonWithTitle:(nullable NSString *)title atIndex:(NSUInteger)index;

// Append buttons at indexes with titles.
- (void)appendButtonsWithTitles:(NSArray<NSString *> *)titles atIndexes:(NSIndexSet *)indexes;

- (void)appendButtonsWithTitles:(NSArray<NSString *> *)titles atIndexSet:(NSIndexSet *)indexSet;
@end
```
* 修改属性类型:
```objc
@interface LCActionSheet : UIView
@property (nullable, nonatomic, strong) NSSet<NSNumber *> *destructiveButtonIndexSet;
// ->
@property (nullable, nonatomic, strong) NSIndexSet *destructiveButtonIndexSet;
@end
```

* 修改方法命名:

```objc
@interface LCActionSheet : UIView

- (void)appendButtonTitles:(nullable NSString *)buttonTitles, ... NS_REQUIRES_NIL_TERMINATION;

// ->

- (void)appendButtonsWithTitles:(nullable NSString *)titles, ... NS_REQUIRES_NIL_TERMINATION;

@end
```
Expand Down
6 changes: 3 additions & 3 deletions Sources/LCActionSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ typedef void(^LCActionSheetDidDismissHandler)(LCActionSheet *actionSheet, NSUInt
/**
Append buttons at indexes with titles.
@param titles titles
@param indexes indexes
@param titles titles
@param indexSet indexSet
*/
- (void)appendButtonsWithTitles:(NSArray<NSString *> *)titles atIndexes:(NSIndexSet *)indexes;
- (void)appendButtonsWithTitles:(NSArray<NSString *> *)titles atIndexSet:(NSIndexSet *)indexSet;

/**
Show the instance of LCActionSheet.
Expand Down
8 changes: 4 additions & 4 deletions Sources/LCActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,16 @@ - (void)appendButtonWithTitle:(NSString *)title atIndex:(NSUInteger)index {
[self updateTableView];
}

- (void)appendButtonsWithTitles:(NSArray<NSString *> *)titles atIndexes:(NSIndexSet *)indexes {
- (void)appendButtonsWithTitles:(NSArray<NSString *> *)titles atIndexSet:(NSIndexSet *)indexSet {
#ifdef DEBUG
NSAssert(titles.count == indexes.count, @"Count of titles differs from count of indexs");
NSAssert(titles.count == indexSet.count, @"Count of titles differs from count of indexs");
#endif

NSMutableIndexSet *indexSetM = [[NSMutableIndexSet alloc] init];
[indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL * _Nonnull stop) {
[indexSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL * _Nonnull stop) {
#ifdef DEBUG
NSAssert(idx != 0, @"Index 0 is cancel button");
NSAssert(idx <= self.otherButtonTitles.count + indexes.count, @"Index crossed");
NSAssert(idx <= self.otherButtonTitles.count + indexSet.count, @"Index crossed");
#endif

[indexSetM addIndex:idx - 1];
Expand Down

0 comments on commit 2fdb8ed

Please sign in to comment.