ios - What kinds of errors does a func throw out in Swift? -


i see methods throw out errors in apple's documentation. can't find information throws.

like methods below. it's in filemanager class.

func moveitem(at srcurl: url, dsturl: url) throws 

i want know kinds of errors throws. can related information?

unlike java, throws declaration requires type, in swift not know, type of error thrown. thing know object conforms error-protocol.

if know function throws certein error (because it's documented), need cast caught object properly.

example:

do {     try moveitem(from: someurl, to: otherurl) } catch {     //there automatically local variable called "error" in block     // let's assume, function throws moveitemerror (such information should in documentation)     if error moveitemerror {         let moveerror = error as! moveitemerror //since you've checked error moveitemerror, can force-cast     } else {         //some other error. without casting it, can use properties , functions declared in "error"-protocol     } } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -