Why Are Iboutlets Optionals After Swift 5 Migration

Why create Implicitly Unwrapped Optionals , since that implies you know there's a value?

Consider the case of an object that may have nil properties while it's being constructed and configured, but is immutable and non-nil afterwards (NSImage is often treated this way, though in its case it's still useful to mutate sometimes). Implicitly unwrapped optionals would clean up its code a good deal, with relatively low loss of safety (as long as the one guarantee held, it would be safe).

(Edit) To be clear though: regular optionals are nearly always preferable.

Swift 3: Expression implicitly coerced from 'UIView?' to Any

In my case it was an issue related to a dictionary without explicit type:

let dict = ["key": value]

Than I solved specifying the type:

let dict: [String: Any] = ["key": value]

In your case you can specify your value type:

let dict: [String: UIView] = ["key": value]

migrated to swift 3 now getting error argument labels '(_:)' do not match any available overloads

There is a major change in Swift 3

  • It's required that all methods / functions provide a label for the first parameter. It's possible to suppress that rule by the underscore character but Apple changed all relevant methods to conform to that rule. So you have to write

    userName = NSString(string:loginUserName.text) 

The other issue occurs because uppercased has been changed to uppercased()


Why do you create a String from something which is a String anyway?

By the way, this is Swift. Use String rather than NSString.

var userEmail = ""
var userName = ""
var userPassword = ""
var userNamePass = ""

userName = loginUserName.text ?? ""
userPassword = loginPassword.text ?? ""
userNamePass = userName.uppercased() + userPassword.uppercased()


Related Topics



Leave a reply



Submit