Instantiated Optional Variable Shows as Nil in Xcode Debugger

Instantiated optional variable shows as nil in Xcode debugger

It appears I've found a bug in Xcode 11. It's easily reproducible as outlined in the UPDATE above. I've filed the bug with Apple.

I'm still looking for a workaround now, since I use quite a few structs containing Date variables. If anybody can find one, please comment below.

Xcode returns nil on string that isn't optional

This code is crashing due to force unwrapping. In this case can recommend to use URLComponents.This is more readable than the string joining and for large number of parameter string joining is not a good option.

var components = URLComponents()
components.scheme = "http"
components.host = "mywebsite.com"
components.path = "/api/v0.1/Business/EditBusinessLogoAndCategory"
components.queryItems = [
URLQueryItem(name: "businessID", value: bizID),
URLQueryItem(name: "category", value: category)

]
let url = components.url



enter code here

Xcode debugger doesn't print objects and shows nil, when they aren't

Are you sure you are not in "Release mode"?

If you want to see variable values you have to be in "Debug mode" (click on your project name on the top left corner near start/stop buttons, then "Edit scheme...", then "Run" settings, then "Info" tab, then "Build Configuration". Here set "Debug". If it was on "Release" that's the matter you saw all nils).

Problem: My non optional variable is nil. (Fatal Error while unwrapping)

Its nil because your outlet is broken. Since you declared it as an implicitly unwrapped optional, balanceLabel.text = String(balanceValue) is the same as balanceLabel!.text = String(balanceValue). You can verify this is tru by simply using optional unwrapping (an implicitly unwrapped optional is still an optional): balanceLabel?.text = String(balanceValue). Go into your storyboard, right click the label and look at the connections. break any existing connections and then recreate the binding to your variable.



Related Topics



Leave a reply



Submit