From an API design standpoint, it seems to me that the use of Implicitly Unwrapped Optional (IUO) in method signature only benefits the method code (to not have to unwrap) instead of the caller.
Take this open source code for example:
class func getStationDataWithSuccess(success: ((metaData: NSData!) -> Void)) {
if useLocalStations {
getDataFromFileWithSuccess() { data in
success(metaData: data)
}
} else {
loadDataFromURL(NSURL(string: stationDataURL)!) { data, error in
if let urlData = data {
success(metaData: urlData)
}
}
}
}
I see no value in metaData being declared as an IUO when it can be optional, or is there a reason why this method parameter should be declared as such?
Therefore, from an API design standpoint, it seems to me that Optional should always be a better practice over IUO (based on concrete reasons, not opinions)