UrbanPro
true

Learn Mobile App Development from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Swift Constants

Satish S
13/12/2016 0 0

Objective C Provides  a way to declare constant using Const keyword.
In Objective C we often use #define for declaring a macro.
Swift the way to declare constants is different from objective C.

Let is used to declare a constant in Swift Language.
 
let a: String="hello World!"
 
Let tells the compiler that 'a' is the name of the variable which is constant Constant.
String tell the type of the constant that a stores.
Declaring constants and using then is similar to using immutable classes like NSString,NSArray etc.
NSString *a=@"hello World!"
In the above line a is pointer to NSString address which is Immutable i.e whose address content cant be changed.
Let me describe the difference between using const * and *const pointers.
 
int a = 10; int b = 15; 
int *const ptr = &a;
*ptr = 20; // OK. a is now 20.
ptr = &b; // Error, ptr is a constant.
 
The above declaration should be read from left to right. The above code declares a const pointer to int.
Pointer ptr can't be made to point do different variable.
0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

How to Make an Awesome Image Classifier With Tensorflow in iOS in less than 5 minutes.
What is TensorFlow? Tensorflow is an Open source machine learning framework. Its a library for doing Complex Numerical Computation to build machine learning models from scratch. TensorFlow is cross-platform....

Starting Career in Android Development
Starting career in Android has become trouble free now. There is a lot of content available online to start learning Android. Just type “Android development” in Google and you will be flooded...

Microsoft Cognitive Face API (iOS) - Identifying Faces From an Image and Extracting Facial Features Like Age, Gender, Emotions.
Microsoft Cognitive Services is a set of APIs, SDKs and services available to developers to make their applications more intelligent, engaging and discoverable. You can basically do a lot of cool stuffs...

What Is Swift?
1. It is a new programming language that was created by Apple. 2. It is entirely built from the ground up. 3. It was announced at the WWDC in June of 2014. 4. But it was in development for number of...
R

The Best Option JavaScript Language For Developers
We already know about JavaScript. But today I will be discussing JavaScript features and JavaScript development process. I was wonder about JavaScript last 10 years. Because JavaScript can give us frontend...
X

Looking for Mobile App Development Classes?

The best tutors for Mobile App Development Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Mobile App Development with the Best Tutors

The best Tutors for Mobile App Development Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more