Category Archives: Swift Language Tutorials

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’s the value hold 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:

 

willSet method swift programming – how it works ?

willSet method swift programming The code that’s written in this method is run anytime outside the initializer.

On setting up square sideLength, it will set the triangle sideLength by self. There’s another method didSet as well and that we will see in later on posts.