Basic init rules in Swift

I kept wondering whether you’re supposed to call the parent init method before or after your code and I found a basic answer:

init() {
    // Put values into your instance variables and constants

    super.init()

    // Other initialization code, such as calling methods, goes here
}

 

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.