Swift (Rules and variable declaration, initialization)

Well for the programming language for an ios is swift either we can use an objective c or with well I prefer swift as I am comfortable it .


In previous post we had talked about what is development in ios lets brief up first of all in android app we needed two files a java file and an xml file one for code and other business logic here also storyboard for U.i. design and ViewController.swift for business also its configuration file is info.plist.

Now coming back to swift there are some rules for it as follows
  • Semi colon(;) is not required end of statement.
  • Do not require variable declaration with specific Data type.
  • narrow or broad conversion that is casting must be done by the user.
  • To display text we have print("text") or println("text").
  • for a variable to print we have to write \(var) or for example \(a+b).
Rules for declaring variables ....
  • var var_name
with type annotation ....
  • var var_name:datatype
initializing  a variable.....
  • var var_name=value
with data type
  • var var_name:datatype=value
declaring constant we can write

let Constant_name=value








 

Comments

Popular posts from this blog

State space search / blocks world problem by heuristic approach /TIC TAC TOE

Navigation in Vaadin.

Drag and drop items from one Grid to another