繁体   English   中英

将 Objective-C 转换为 Swift 代码

[英]Converting Objective-C to Swift Code

NSDictionary *detectorOptions = [[NSDictionary alloc] initWithObjectsAndKeys:CIDetectorAccuracyLow, CIDetectorAccuracy, nil];

self.faceDetector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:detectorOptions];

请帮我把它转换成swift。

我从 iCapps 引用了这段代码。 我只学过 Swift。 我试图低估代码,但它有点令人困惑。 有高手知道的请帮帮我。 并建议我一些轻松将 Obj-C 转换为 Swift 的想法。

let detectorOptions = [CIDetectorAccuracy: CIDetectorAccuracyLow]
self.faceDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: detectorOptions)

SWIFT代码:

var detectorOptions: [NSObject : AnyObject] = [
    CIDetectorAccuracy : CIDetectorAccuracyLow
]

self.faceDetector = CIDetector.detectorOfType(CIDetectorTypeFace, context: nil, options: detectorOptions)

我已经为你转换了它,但如果你不知道 swift,现在开始使用这个网站https://objectivec2swift.com进行转换

var detectorOptions: [NSObject : AnyObject] = [
    CIDetectorAccuracy : CIDetectorAccuracyLow
]
self.faceDetector = CIDetector.detectorOfType(CIDetectorTypeFace, context: nil, options: detectorOptions)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM