您的当前位置:首页正文

关于iOS9禁用的那些api取代方法

来源:图艺博知识网

列表:(1)- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding

(2)UIAlertView 、ActionSheet 在iOS9 中由 UIAlertController取代

(3)NSURLConnection sendSynchronousRequest.../sendAsynchronousRequest... deprecated,现在只能使用NSURLSession

(4)stretchableImageWithLeftCapWidth:topCapHeight:  deprecated in iOS2.0,

use resizableImageWithCapInsets:

(1)- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding

原用法:

urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *url = [NSURL URLWithString:urlString];

新用法:

For Objective-C:

NSString *str = ...; // some URL

NSCharacterSet *set = [NSCharacterSet URLHostAllowedCharacterSet];

NSString *result = [str stringByAddingPercentEncodingWithAllowedCharacters:set];

取代

(2)UIAlertView 、ActionSheet 在iOS9 中由 UIAlertController取代

另:UIAlertController 可增加UITextField

(3)NSURLConnection sendSynchronousRequest/sendAsynchronousRequest deprecated,现在只能使用NSURLSession

Top