NSURL getResourceValue in swift

前端 未结 5 863
梦如初夏
梦如初夏 2021-02-13 11:54

Having trouble figuring out how to make the following call in swift:

var anyError: NSError? = nil
var rsrc: NSNumber? = nil
var success = url.getResourceValue(&a         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-13 12:17

    Here is drewag's code updated for Swift 2.0

        do {
            var rsrc: AnyObject?
            try element.getResourceValue(&rsrc, forKey: NSURLIsDirectoryKey)
            if let number = rsrc as? NSNumber {
                if number == true {
                    // do something
                }
            }
        } catch {
        }
    

提交回复
热议问题