简体   繁体   中英

Converting Objective-C to Swift Code

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

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

Please help me to convert this into swift.

I referred this code from iCapps. I have only learned Swift. I tried to understated the code, but its bit confusing. Please help me if any experts knows. And suggest me some ideas to convert Obj-C to Swift easily.

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

Swift Code:

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

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

I have converted it for you, but now onwards use this site https://objectivec2swift.com for conversion if you don't know swift

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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