Reputation: 708
When i was trying to implement one of the protocol, i came across the following syntax.
optional public func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?)
Can anyone explain the meaning of the "didFinishWithResult"? Is it a argument? If not what is it?
Upvotes: 0
Views: 62
Reputation: 1209
In Objective C the method is defined as follows with parameter names:
- (void)mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
When you translate it to swift you can declare external and internal parameters
Function parameters have both an external parameter name and a local parameter name. An external parameter name is used to label arguments passed to a function call. A local parameter name is used in the implementation of the function.
By default, the first parameter omits its external name, and the second and subsequent parameters use their local name as their external name. All parameters must have unique local names. Although it’s possible for multiple parameters to have the same external name, unique external names help make your code more readable.
You write an external parameter name before the local parameter name it supports, separated by a space:
func someFunction(externalParameterName localParameterName: Int) {
// function body goes here, and can use localParameterName
// to refer to the argument value for that parameter
}
Upvotes: 1
Reputation: 14063
didFinishWithResult
is the external parameter name. result
is the internal one. So, when you call the method, the external is used and within the method the internal is used.
Upvotes: 6