objective-c - ios ,关于方法被弃用的问题?
迷茫
迷茫 2017-05-02 09:19:45
0
3
515

比如,一个方法在iOS8.0 被弃用了,我们都替换成苹果建议使用的方法,那如果iOS8.0之前的版本手机,装上了这个应用。因为8.0之前没有替换后的方法,那调用到这个方法的时候,会不会出现什么问题?

例如:

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
大家讲道理

If this method was added after ios8, then if the phone is still running on ios7, an error will occur. This is the same as android and requires manual control.

仅有的幸福

The deprecation is actually just no longer updated. In fact, it can still be used but there will be a warning. If you think manual control is more troublesome, you can still use this method.

迷茫

There will be problems and even crashes.

For the case of method Deprecated, it can generally be handled like the following:

NSString *sampleString = @"abcdefg";
if ([sampleString respondsToSelector:@selector(stringByReplacingPercentEscapesUsingEncoding:)]) {
    [sampleString stringByReplacingPercentEscapesUsingEncoding:<#your-encoding-here#>];
}
else {
    <#your-else-code-here#>
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template