Sobes.tech
Junior — Middle

What is the default access level for a class member if no other is explicitly specified?

sobes.tech AI

Answer from AI

In iOS (Objective-C and Swift), the default access level for class members depends on the language:

  • In Objective-C, if no access modifier is explicitly specified, class members are considered @protected — accessible within the class and subclasses.

  • In Swift, the default access level is internal, meaning accessible within the module (application or framework), but not outside.

Example in Swift:

class MyClass {
    var value = 10  // internal by default
}

Therefore, without explicitly specifying public, private, or fileprivate, the value property will be accessible within the current module.

What is the default access level for a class member… - sobes.tech