最近使用Swift编程中,遇到一个问题,就是出现了Call can throw, but it is not marked with ‘try’ and the error is not handled的错误。
我做的是获取视频的首帧图片,在使用到 copyCGImageAtTime(requestedTime: CMTime, actualTime: UnsafeMutablePointer<CMTime>) throws -> CGImage
方法时,出现了Call can throw, but it is not marked with ‘try’ and the error is not handled的错误。刚开始以为是参数的错误,因为在OC该方法是这样的- (nullable CGImageRef)copyCGImageAtTime:(CMTime)requestedTime actualTime:(nullable CMTime *)actualTime error:(NSError * __nullable * __nullable)outError
,纠结好久,上网查阅相关资料,解决了!下面看一下:
这是OC中方法的解释:
/*!
@method copyCGImageAtTime:actualTime:error:
@abstract Returns a CFRetained CGImageRef for an asset at or near the specified time.
@param requestedTime
The time at which the image of the asset