-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code cleanup for your pull request #1
Changes from all commits
29ae366
2588541
f176272
ab80aff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,10 +293,10 @@ - (IBAction)customButtonPressed:(id)sender | |
NSDictionary *buttonDetails = (self.customButtons)[(NSUInteger) index]; | ||
NSAssert(buttonDetails != NULL, @"Custom button dictionary is invalid"); | ||
|
||
ActionType actionType = [buttonDetails[kActionType] intValue]; | ||
ActionType actionType = (ActionType) [buttonDetails[kActionType] integerValue]; | ||
switch (actionType) { | ||
case Value: { | ||
NSInteger buttonValue = [buttonDetails[kButtonValue] intValue]; | ||
NSInteger buttonValue = [buttonDetails[kButtonValue] integerValue]; | ||
UIPickerView *picker = (UIPickerView *) self.pickerView; | ||
NSAssert(picker != NULL, @"PickerView is invalid"); | ||
[picker selectRow:buttonValue inComponent:0 animated:YES]; | ||
|
@@ -310,16 +310,16 @@ - (IBAction)customButtonPressed:(id)sender | |
|
||
case Block: { | ||
ActionBlock actionBlock = buttonDetails[kButtonValue]; | ||
[self hidePickerWithCancelAction]; | ||
[self dismissPicker]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Возможно у человека висит некоторый специфичный cancelBock, который он не хотел бы выполнять при нажатии на кнопку. Так что лучше просто скрывать пикер. |
||
if (actionBlock) | ||
actionBlock(); | ||
break; | ||
} | ||
|
||
case Selector: { | ||
SEL selector = [buttonDetails[kButtonValue] pointerValue]; | ||
id target = buttonDetails[kActionTarget]; | ||
[self hidePickerWithCancelAction]; | ||
[self dismissPicker]; | ||
if (target && [target respondsToSelector:selector]) | ||
{ | ||
SuppressPerformSelectorLeakWarning ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,7 +371,7 @@ - (void)customButtonPressed:(id)sender { | |
NSDictionary *buttonDetails = (self.customButtons)[(NSUInteger) index]; | ||
NSAssert(buttonDetails != NULL, @"Custom button dictionary is invalid"); | ||
|
||
ActionType actionType = [buttonDetails[kActionType] intValue]; | ||
ActionType actionType = (ActionType) [buttonDetails[kActionType] intValue]; | ||
switch (actionType) { | ||
case Value: { | ||
id itemValue = buttonDetails[kButtonValue]; | ||
|
@@ -385,16 +385,10 @@ - (void)customButtonPressed:(id)sender { | |
break; | ||
} | ||
|
||
case Block: { | ||
case Block: | ||
case Selector: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лучше писать так, когда нужно сделать одно действие для нескольких кейсов. |
||
[super customButtonPressed:sender]; | ||
break; | ||
} | ||
|
||
case Selector: { | ||
[super customButtonPressed:sender]; | ||
break; | ||
} | ||
|
||
default: | ||
NSAssert(false, @"Unknown action type"); | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
static const float delay = 0.f; | ||
|
||
static const float duration = .3f; | ||
static const float duration = .25f; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это моя правка, осталась от еще незапушеного комита. |
||
static const enum UIViewAnimationOptions options = UIViewAnimationOptionCurveEaseIn; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
по поводу
integerValue
: Конечноtypedef int NSInteger;
Но лучше всегда использовать родные типы данных. Тем более "вдруг" измениться архитектура и
NSInteger
станет ужеlong int
(к примеру)?По поводу каста к типу ActionType - это нужно для проверок на этапе компиляции. AppCode такие вещи сразу подсвечивает и при курсоре на этих участках и нажатии Alt + Enter сразу правит.