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

What Are IT Industries Performance Metrics?
1. Outstanding Expectation: Eligible to get Promotion easily and good salary hike. Always preferrable to go abroad. 2. Exceed Expectation: Can get Promotion as per schedule of company with good salary...

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

Introduction to Android
What is Android? We can define Android in three points, - Os for Mobile devices - Open Source - Based on Linux Kernal 2.6 What we are going to learn in this course, - In this course we are going...

What Would Be Life Cycle Of A Fresher After Campus In An IT Company?
1. Basic Technical Training: Since freshers are not subject matter experts so gone through 3 - 6 months basic technical training within Organization. 2. Technical Assessment: HR sends freshers to various...

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