Powered by
Powered by
HuntMyIdeas-Inspire You To Make It Happen
Follow
   Me
  • Blogs
  • About Me
  • Home

An Introduction To The Swift Programming Language

5/18/2016

0 Comments

 
Picture
This tutorial is aimed at the developers with no experience in Swift programming language.This Tutorial is designed to illustrate the basic concept of Swift programming from beginner level to mid level iOS developers.Let's go through some basics of syntax,before creating your first Swift project. 
What is Swift ?

Swift is another powerful and intuitive  programming language by apple to make Apps for iOS, OS X, watchOS, and tvOS .

​Swift adopts the best of C and Objective-C, without the constraints of C compatibility.
Why Apple named the language as Swift?
​

Apple developers designed the language keeping some goals in mind:
1)Faster coding
2)Faster execution


Why should you choose Swift as a programming language ?

1)Swift follows safe programming patterns 

2)Swift includes latest features for easy programming,flexibility and more fun.

3)The syntax of Swift programming language was designed to be clean and easy to read.
4)Swift provides syntax similar to Objective C

5)Swift provides playground feature where the iOS developers can see the result of execution after writing their code.

6)Swift is based upon some great ideas from various other popular languages such as Objective-C, Rust, Haskell, Ruby, Python, C#, and CLU.

7)Swift will not only supports Objective-C ,but it will also replace C for embedded programming on Apple platforms.


How to declare variables in Swift ?

Declaring a variable tells the compiler where and how much to create the storage for the variable. 
If you want to use variables in Swift,you should declare them using var keyword:

Example:

How to declare an integer variable in Swift ?

You should  use Int instead of Integer

var value:Int
value = 2
Declaring Variable in one line:
var value:Int = 2
Using Type inference
var value = 2
Swift has feature called type inference where it can infer the type of the variable based on the value you assign to it. 
How to declare String Variable in Swift ?
var quality : String = "best"


Note:
We can declare class level instance variables and local variables in methods in Objective C but in Swift,we can't declare class-level variables ,only local variables that we can declare within  methods.
We have can create a class-level instance variable by declaring properties.
How to declare constant Variables in Swift?
Constants are only meant to be used with values that will never change.If you edit the constant variable,it will through an error.
let result = 42     //Constant


let is the type for a Swift constant.You must always initialize your let constants, even if you explicitly type them
Example:
What happens if we try to change Swift constant.

let value = 42
value = 21//Error:  Cannot assign to 'let' value  'value'

Read:
Swift Interview Questions And Answers part 1


0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Enter your email address:

    Delivered by FeedBurner

    RSS Feed

    Archives

    December 2019
    August 2018
    January 2018
    December 2017
    November 2017
    October 2017
    August 2017
    April 2017
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014


    ​​Categories

    All
    Affiliate Marketing
    Alexa Rank
    Apple's Latest Updates
    Blog Tips
    Cocos2d X
    Cocos2d-x
    Google AdSense Tips
    Grab-some-ultimate-ideas
    How-to-create-a-twinkling-star-background-effect-in-ios
    In-App Purchase Tutorial In Cocos2d-x (C++) Using SDKBOX
    Ios Interview Questions And Answers
    IOS Multiple Choice Questions And Answers
    Objective C
    Online Business
    Python
    Secrets To Effective IPhone App Marketing
    SEO Tips
    Swift Interview Questions
    Swift Tutorials
    Top 10 Articles Objective C
    Top 10 Articles-Objective-C
    Top 10 Popular Movies Ever
    Top 10 Popular Things To Know
    Top 10 Ultimate Issues Xcode
    Top 400 IOS Interview Questions
    Top IOS Sample Projects To Learn From
    Top Secrets To App Marketing
    UICollectionView
    Unity 3D
    Xcode

WELCOME TO HUNTMYIDEAS

Picture
I am Jitendra Gochhayat,an iOS Developer,Designer,blogger,
​from Odisha,India.
I write about ​​​blog tips and,
Make money online Tips,
​Objective C tutorials
SUSCRIBE TO NEWSLETTER

    Subscribe to this blog and receive notifications of new posts by email

Suscribe
Picture
Picture
Picture
Picture
Picture
HuntMyIdeas-2016 Powered By Weebly
Picture
Powered by Create your own unique website with customizable templates.
Powered by
Powered by