【发布时间】:2015-11-04 15:20:37
【问题描述】:
我有一些在 ios 7 和 8 中运行良好的警告。当我们使用 iOS 9 时,它给了我一个警告。
这是警告:
'appearanceWhenContainedIn:' 已弃用:首先在 iOS 9.0 中弃用 - 改用 +appearanceWhenContainedInInstancesOfClasses:
所以我使用了这个代码:
[[UITextField appearanceWhenContainedInInstancesOfClasses:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
代替这段代码:
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
但是当我使用时,我得到了错误:
方法调用的参数过多,预期为 1,有 2 个
警告:
'base64Encoding' is deprecated: first deprecated in iOS 7.0
在下面的代码中:
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64Encoding]];
警告:
'searchDisplayController' is deprecated: first deprecated in iOS 8.0
在下面的代码中:
[self filterContentForSearchText:searchText scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
警告:
'sendSynchronousRequest:returningResponse:error:' is deprecated: first deprecated in iOS 9.0 - Use [NSURLSession dataTaskWithRequest:completionHandler:] (see NSURLSession.h
在下面的代码中:
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
我正在使用 iOS9。我需要删除所有这些警告。提前致谢!
【问题讨论】:
-
如果您在有问题的方法上单击命令,您将跳转到定义,并且在许多情况下,弃用通知应该告诉您改用什么方法。例如,
+appearanceWhenContainedInInstancesOfClasses:现在采用NSArray的Class对象,而不是va_args的Class对象列表。
标签: ios objective-c