Value' Is Inaccessible Due to 'Internal' Protection Level

value' is inaccessible due to 'internal' protection level

Thanks for trying Alamofire 5! This error is a bit misleading, as the Swift compiler is trying to be helpful and letting you know there's an internal property value on response.result that you can't access. However, this is an internal Alamofire extension, as we moved to the Result type provided by the Swift standard library in Alamofire 5 beta 4. The system Result does not offer the the value and error properties that Alamofire's previously provided Result type did. So while we have extensions internally to provide functionality to us, they do not exist publicly for use by your app.

The ultimate solution here is up to you. You can extend Result yourself to offer the properties (feel free to use the Alamofire implementation) or you can do without the properties and switch over the response.result value to extract the response value. I would suggest using switch for now, as it forces you to consider the .failure case.

Initializer is inaccessible due to 'internal ' protection level

First there are five different protection levels: private, fileprivate, internal, public and open.

Any property, func or your initialiser you declare without a protection level keyword will automatically declared as internal.

Internal means, that your property, method or initialiser is accessible everywhere within the same module.

It seems like you are trying to create a new struct out of another module. Best solution would probably be to create your own init instead of the automatically generated one and declare it also as public.

Hope this helps you.

MyEnum' is inaccessible due to 'internal' protection level

The static properties are still internal by default, you have to declare them public too:

public class LoggerStartup : NSObject
{
public enum eTables
{
public static let users = 100
public static let types = 200
public static let items = 300
public static let measures = 400
}
}

Of course, this would be different, if you used an actual enum:

public enum eTables: Int {
case users = 100
case types = 200
case items = 300
case measures = 400
}

In that case you would be able to use eTables.types directly.

phoneFieldChanged' is inaccessible due to 'internal' protection level

The error message is surprisingly descriptive here. Take a look at PhoneVerificationController definition. Most probably phoneNumberField property is specified with internal access level, which means it is accessible only within module where it is defined and most probably this is a 3rd party dependency since it's not accessible in your source code.

To solve this error you can:

  1. Change access level to public

  2. Take a closer look at documentation of PhoneVerificationController and find out which public API it has to address your specific use-case

isSuccess' is inaccessible due to 'internal' protection level, AlamoFire not working like before

result is now of the built-in Result enum type, which means you can do pattern matching on it. Your code can be rewritten as:

AF.request("", method: .get, parameters: [:]).responseJSON { (response) in
if case .success(let value) = response.result {
print("Got the info")
print(response)

let flowerJSON : JSON = JSON(value)
...
}
}

Use a switch statement if you want the error case as well:

switch response.result {
case .success(let value):
// ...
case .failure(let error):
// ...
}


Related Topics



Leave a reply



Submit