willSet didSet example swift – How to use ?

willSet didSet example swift willSet and didSet are called property observers. They observe the changes in the value of a property. willSet observe what changes are made that means new value and didSet observe what change was made that is old value.

 

structure example swift programming

structure example swift programming Here’s a simple structure example in swift. We are creating three structures. One with get and set methods. Later we are initializing their instances. How get and set method works is written in code.

 

cannot convert return type int to return type ()->int

cannot convert return type int to return type ()->int If you are working with nested functions and you face such error while returning a function then see if you haven’t used parentheses after function name after return.

 

Closures example swift – How to write ?

Closures example swift – How to write ? Closure gives the feature to write an inline function block. Here. we have taken an example of array mapping.

Notice the “!” mark in dictionary subscript. It is used because a dictionary always returns an optional value making sure the case that a key might contain… Read More »

defer swift – what is defer in swift ?

defer swift – what is defer in swift ? It’s similar to the finally{} black used in C++ and Java. That means the code in defer will run anyways no matter what.

 

Structure swift language programming – struct

Structure swift language programming – struct Structure in swift is similar to C structures and also similar to class in swift. One of the most important differences between structures and classes is that structures are always copied when they are passed around in your code, but classes are passed by reference.

 

rawValue enum swift – what is rawValue ?

rawValue enum swift – what is rawValue ? It is the value held by name in enum. By default, swift assigns enum value as zero and then incrementing by one. For accessing rawValue, we can see example below: