Thanks, I ended up finding a solution myself... it appears I was misunderstanding the way the static keyword works in Swift.
Here's what I ended up with (minus error checking that would go into the real code, of course):
class foo {
static var a: String?
func printit() {
print(foo.a)
}
}
class bar: foo {
}
foo.a = "def"
let someBar = bar()
someBar.printit()
This does what I want. Your point about being cautious with these things is taken; not to worry, this isn't something I plan to do much of, but it does provide a cleaner solution to tie this to the class rather than making it a true global. 🙂
Topic:
Programming Languages
SubTopic:
Swift
Tags: