I see a Swift function written as follows:
func calculation(imageRef: CGImage) -> (red: [UInt], green: [UInt], blue: [UInt]) {
...
...
}
I need to know what is the return type in the function above. I am unable to relate it to any of the known types & also what is its equivalent in Objective-C if any at all? What's the way to translate this function to Objective-C?
This method return a tuple
It's a tuple that this function is returning.
A tuple can hold various types in one object, but unlike an array, you cannot append or remove objects to/from it.
From Apple Developer Swift Guides:
Tuples don't exist in Objective-C. You can find more information about that here.
The above method returns tuple (A group of different values that you can use in Swift).
You can also return tuple without named parameters:
You can access the return values like this (For un-named tuple parameters):
or (For named tuple parameters):
There is no equivalence of tuple in Objective-C.
This called
Tuple
learn hereit allows to group multiple values under single variable.
Objective c don't support tuple . in objc you have to use
dictionary
and you have to use keyred
,green
and 'blue
with array as value