Open
Conversation
Codecov Report
@@ Coverage Diff @@
## master #53 +/- ##
==========================================
- Coverage 56.49% 54.12% -2.37%
==========================================
Files 29 32 +3
Lines 924 981 +57
==========================================
+ Hits 522 531 +9
- Misses 402 450 +48
Continue to review full report at Codecov.
|
jezzmemo
reviewed
Feb 16, 2019
Owner
jezzmemo
left a comment
There was a problem hiding this comment.
由于在PR里没有写规范,为了保持组件的代码规范,所以麻烦和我的风格保持一致,主要以下问题:
1.大括号不需要换行
2.布尔类型不需要==
3.变量要明确
4.注释最好英文,以便国际化
5.函数上下空行
如有问题,随时交流
| #import "JJPerson.h" | ||
|
|
||
| @implementation JJPerson | ||
| + (BOOL)accessInstanceVariablesDirectly |
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @interface NSObject (KVCCrash) | ||
| + (void)jj_swizzleKVCCrash; |
|
|
||
| - (void)hookSetValue:(id)value forKey:(NSString *)key | ||
| { | ||
| if (key.length == 0) return; |
Owner
There was a problem hiding this comment.
if (key.length == 0) {
return;
}
|
|
||
| NSString *methodSuffix = [NSString stringWithFormat: @"%@%@", [[key substringToIndex: 1] uppercaseString], [key substringFromIndex: 1]]; | ||
|
|
||
| // 1、判断setKey方法是否存在 |
| NSString *methodSuffix = [NSString stringWithFormat: @"%@%@", [[key substringToIndex: 1] uppercaseString], [key substringFromIndex: 1]]; | ||
|
|
||
| // 1、判断setKey方法是否存在 | ||
| SEL setXXSelector = NSSelectorFromString([NSString stringWithFormat: @"set%@", methodSuffix]); |
| - (void)keyButtonClick | ||
| { | ||
| JJPerson *p = [JJPerson new]; | ||
| [p setValue: @"123" forKeyPath: @"age"]; |
|
|
||
| @implementation NSObject (KVCCrash) | ||
| + (void)jj_swizzleKVCCrash | ||
| { |
| Method setXXMethod = class_getInstanceMethod([self class], setXXSelector); | ||
|
|
||
| if (setXXMethod) | ||
| { |
| // 2、判断_setKey方法是否存在 | ||
| SEL _setXXSelector = NSSelectorFromString([NSString stringWithFormat: @"_set%@", methodSuffix]); | ||
| Method _setXXMethod = class_getInstanceMethod([self class], _setXXSelector); | ||
| if (_setXXMethod) |
| } | ||
|
|
||
| // 2、判断_setKey方法是否存在 | ||
| SEL _setXXSelector = NSSelectorFromString([NSString stringWithFormat: @"_set%@", methodSuffix]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
您好,添加了对KVC崩溃的Hook