What does 'fileprivate' keyword means in Swift?

Nathaniel picture Nathaniel · Sep 16, 2016 · Viewed 28.5k times · Source

I'm starting in swift and opening a project created using swift2 from xcode 8 beta, the private modifier were changed to fileprivate. what does this keyword means? and how is different from private ?

Answer

Jans picture Jans · Sep 16, 2016

fileprivate is one of the new Swift 3 access modifiers that replaces private in its meaning. fileprivate defines an entity (class, extension, property, ...) as private to everybody outside the source file it is declared in, but accessible to all entities in that source file.

private restricts the entity in the direct enclosing scope.