Passing 0 as an enum option into Objective C functions in Swift

前端 未结 1 1348
死守一世寂寞
死守一世寂寞 2021-01-18 21:05

There are Objective-C libraries with functions that take integer enum options as a parameter, but they expect you to pass 0 in if you want default options, as is typical. Bu

1条回答
  •  -上瘾入骨i
    2021-01-18 21:21

    As of Swift 2, the syntax for option sets was changed to use array literals. So if you want to pass no options, you pass an empty list:

    SDWebImageManager.sharedManager().downloadWithURL(url, options: [], progress: nil) { (image:UIImage!, error:NSError!, cacheType:SDImageCacheType, finished:Bool) -> Void in
        // code here
    }
    

    0 讨论(0)
提交回复
热议问题