ChenYilong / ChenYilong/iOS13AdaptationTips
新系统 KVC crash 风险
- Dominant language
- No language data
- Stars
- 170
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
## KVC 修改_placeholderLabel Crash
版本 | Crash情况
:-------------:|:-------------:
App Store版本| 旧版本不会Crash
使用Xcode11编译上传版本| 会crash
iOS13 | 与系统无关,只与Xcode版本有关
## UITextField
iOS 13(beta版本) 上 UITextField 的 _placeholder 拿不到了,KVC 还是有风险:
```Objective-C
[textField setValue:[UIColor xxx] forKeyPath:@"_placeholderLabel.textColor"];
```
> . reason: 'Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug'
App Store 上的旧版本,不会因为kvc 闪退。使用Xcode11编译上传版本才会Crash。
经 SAGESSE-iOS-深圳 使用dis命令分析,为系统检测了该内部字段,非误伤。
```Objective-C
dis -n "-[UITextField valueForKey:]"
```


## UISearchBar
```Objective-C
[self setValue:@"xxx " forKey:@"_cancelButtonText"];
```
iOS 13 的 seachbar 添加了一个 `- (void)set_cancelButtonText:(NSString *)text` 方法,这个方法专门用来命中 kvc。一旦命中 就crash

## UIScreen.setBrightness crash in global thread #25
Reference: https://github.com/ChenYilong/iOS13AdaptationTips/issues/25#issue-480076177
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.