|
|
|
|
|
by sadawi
3794 days ago
|
|
To me, something like your syntax makes sense when there isn't a clear hierarchy among selectorPart1, selectorPart2, selectorPart3, etc. However, in every case where a method can be thought of as having a single primary action that is refined by arguments, I believe the action(argument1:value1, argument2:value2) syntax makes more sense. I wouldn't want to see, for example: collectionView.(dequeueReusableCellWithReuseIdentifier:identifier, forIndexPath: indexPath)
because that obscures the primary purpose of the method, which is to dequeue a cell. To me, this is preferable: collectionView.dequeueReusableCell(reuseIdentifier: "ImageCell", îndexPath: indexPath)
The long first component of the Objective C selector ("dequeueReusableCellWithReuseIdentifier") is just an artifact of ObjC's lack of distinction between method names and parameter names, which forces the API creator to use words like "With" to accomplish what Swift can do natively.What are some examples of methods you think make more sense with your syntax? |
|