We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies.

We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies. Less

We use cookies and other tracking technologies... More

Login or register
to apply for this job!

Login or register
to save this job!

Login or register to start contributing with an article!

Login or register
to see more jobs from this company!

Login or register
to boost this post!

Show some love to the author of this blog by giving their post some rocket fuel 🚀.

Login or register to search for your ideal job!

Login or register to start working on this issue!

Engineers who find a new job through Python Works average a 15% increase in salary 🚀

Blog hero image

Difference Between Private and FilePrivate Swift

Muneeb Ali Arshad 29 March, 2020 | 1 min read

In this article, we will discuss Private and Fileprivate in iOS. This is my first article on medium I hope it will be helpful. Now, get started and we will deeply discuss both now:

Private:

Private variables and functions are only accessible in their scope only where they are created. For example, if we have a class and we declare the function or a variable private then it is accessible only in this class. if we try to access this in another class then we can not access it.

Private Example

As you can see when we try to the private variable of the person class then an error appears saying: ‘name’ is inaccessible due to the ‘private’ protection level. Therefore if we want to access the name of the person class we have to make it public as we created an age variable. which is accessible and we can also assign a value to its object.

FilePrivate

Fileprivate variables and functions are accessible within the file they are created. But not in another file and also not in another class as private. Fileprivate Example

As you can see we created file private variable and it’s accessible in the same file easily but if we try to access in another file and class it will give an error.

Originally published on medium.com

Author's avatar
Muneeb Ali Arshad
I am an iOS developer with 4 years of experience, during this period I was involved in the development of such products as geolocation, music and video application, messengers, and social media apps and many more. I have experience across a wide variety of industries, including finance, travel, medicine, fashion. I am comfortable working as part of a team or individually and have an in-depth understanding of emerging technologies in new media.
    Swift
    Objective C
    Xcode
    MapKit

Related Articles

Related Issues

WorksHub / client
  • Started
  • 0
  • 17
  • Intermediate
  • Clojure
  • $150
viebel / klipse-clj
viebel / klipse-clj
  • Open
  • 0
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • Open
  • 0
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • 1
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • Started
  • 0
  • 2
  • Intermediate
  • Clojure
  • $80
viebel / klipse
  • Open
  • 0
  • 0
  • Advanced
  • Clojure
  • $80
viebel / klipse
  • Started
  • 0
  • 2
  • Advanced
  • Clojure
  • $180
viebel / klipse
  • Started
  • 0
  • 1
  • Intermediate
  • Clojure
viebel / klipse
  • 1
  • 1
  • Advanced
  • Clojure
  • $300

Get hired!

Sign up now and apply for roles at companies that interest you.

Engineers who find a new job through Python Works average a 15% increase in salary.

Start with GitHubStart with Stack OverflowStart with Email