我想更新Swift 3的以下方法的命名:
public func imageWithUrl(url: String, placeholderNamed: String) {
if let image = UIImage(named: placeholderNamed) {
imageWithUrl(url: url, placeholder: image)
} else {
imageWithUrl(url: url)
}
}
Run Code Online (Sandbox Code Playgroud)
至
public func image(url: String, placeholderNamed: String) {
Run Code Online (Sandbox Code Playgroud)
所以我用这个方法弃用旧方法:
@available(*, deprecated: 1.8, renamed: "image(url:, placeholder:")
Run Code Online (Sandbox Code Playgroud)
问题是我收到以下错误:
'available'属性的'renamed'参数必须是运算符,标识符或完整函数名称,可选地由类型名称预设
我开始说我花了很多时间在文档,帖子和其他地方搜索,但我无法找到解决这个问题的方法.
我AVAssetExportSession
用于导出.mp4
存储在AVAsset
实例中的文件.我所做的是:
isExportable
属性AVAsset
exportPresets
与AVAsset
实例兼容的数组AVAssetExportPreset1920x1080
,或者,如果不存在,我尝试导出媒体AVAssetExportPresetPassthrough
(仅供参考,100%的时间,我需要的预设总是包含在列表中,但我也尝试了passthrough选项,但它无论如何都不起作用)的outputFileType
是AVFileTypeMPEG4
,我也试图通过分配.mp4
扩展到该文件,但没有什么使得它的工作.我总是收到这个错误
错误域= AVFoundationErrorDomain代码= -11838"操作已停止"UserInfo = {NSUnderlyingError = 0x600000658c30 {错误域= NSOSStatusErrorDomain代码= -12109"(null)"},NSLocalizedFailureReason =此媒体不支持该操作.,NSLocalizedDescription =操作已停止}
下面是我正在使用的代码
func _getDataFor(_ item: AVPlayerItem, completion: @escaping (Data?) -> ()) {
guard item.asset.isExportable else {
completion(nil)
return
}
let compatiblePresets = AVAssetExportSession.exportPresets(compatibleWith: item.asset)
var preset: String = AVAssetExportPresetPassthrough
if compatiblePresets.contains(AVAssetExportPreset1920x1080) { preset = AVAssetExportPreset1920x1080 }
guard
let exportSession = …
Run Code Online (Sandbox Code Playgroud) 现在已经超过5个月,我在Objective-C,我也在App Store发布了我的第一个应用程序,但我仍然怀疑该语言的核心功能.
什么时候我应该使用self
访问iVars,当我不是?
在释放插座时,您self.outlet = nil
在viewDidUnload中dealloc
写入,而不是在您写入时[outlet release]
.为什么?