Posted On: Feb 22, 2018
Swift initializer is a special type of method that can be called to create a new instance of a particular type.
Swift provides a default initializer for any structure or class that provides default values for all of its non-optional properties and does not provide the initializer itself.
Swift initializer Example
class User { var first_name: String var last_name: String init(first_name: String, last_name: String) { self.first_name = first_name self.last_name = last_name } } let p = Person(first_name:"Santosh", last_name:"Botre")
Never Miss an Articles from us.
Swift is an advanced language for iOS development, known for its concise and expressive syntax. It enables fast-running software and is used for developing iOS and OS X applications, making it ideal f..
In Swift, key-value pairs allow for efficient data storage and retrieval, functioning similarly to hash tables in other programming languages. Accessing values is straightforward by using the correspo..
In Swift, enums define a common type for a group of related values, enabling type-safe handling within your code. Essentially, an enum groups various related values under the same umbrella, facilitati..