iOS 10: Swift 3 API Design Guidelines | Ray Wenderlich

OK - your Swift code works, but it's still wrong! Discover how to create Swifty APIs and learn from the best in the form of Cocoa and CocoaTouch.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4990-ios-10-swift-3-api-design-guidelines

@samdavies where can we see the other naming conventions of Swift APIs, is there a list created by Apple? Thanks.

Also, where do you use mutating functions?

Hi @rubiriffic

Swift has a set of API design guidelines available here:

raywenderlich.com has also created our own Swift style guide, which leans heavily on the Swift guidelines (it actually predates it) and focuses on code that works well for teaching. You might like to look at that too:

Mutating functions are those on a struct that actually changes the underlying data. There is some information around mutating functions in the Swift docs:

https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Methods.html#//apple_ref/doc/uid/TP40014097-CH15-ID239

When you have something that is conceptually a value type, and want to change it, it can be perfectly acceptable to mutate it.

Hope that helps,

sam