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 the Best Technologies to Learn for Mobile App Development in 2025?
Mobile app development continues to dominate the tech landscape in 2025. Here are the top technologies you should master: Flutter: Google's cross-platform framework for building apps with a single codebase....

How do i get best Campus / Off Campus Placement?
Companies are looking for Skilled Freshers. So build your technical skills while doing MCA / BTech / BCA / BSc (IT or CS) into below areas- 1. Strong your programming & debugging skills ...

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

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

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