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

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...

Programing Languages Learning Tricks
You want to learn that new language or library or framework as soon as possible, right? That’s understandable. Fortunately, there are a handful of tips that can help you to better retain all of that...

Harshal G.

0 0
0

Benefits of Design Patterns in Application Development
Application developments is a tedious job. Programmers write code and test it again and again to make sure their software works fine. So designing complex software is a hard nut to crack. Skilled programmers...

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...

Broadcast Receiver in Android
How you ever wonder how all your app detects OS events like when the internet is turned ON, the incoming call is coming, battery low etc. like that? Yes, it is because of Android OS build in Event, "Broadcast...
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