What is this type of variable (specifically constant) declaration called that initializes itself with a "stored procedure" with code within curly braces followed by an empty set of parentheses? I don't know what key words to search for.
let object: NSObject = {
let nestedObject = NSObject()
return nestedObject
}()
I want to know if that variable gets initialized when it's needed the first time if I declare it globally in a swift file outside any other scope, or if it is initialized when the iOS app starts up before the variable is even called.
I thought the code within the curly braces runs when the iOS app launches, thus initializing the value of the variable, but I got an run time error while debugging my Xcode project when such a variable is called for the first time. I got a runtime error that says:
EXC_BREAKPOINT (code=1, subcode=0x...)
I also was told at one time in a question I posted on stackoverflow that the code runs only once.