The only work around for this that I've come up with thus far is something that looks like this something that looks like this:
func foo() -> Int {
struct Holder {
static var timesCalled = 0
}
return ++Holder.timesCalled;
}
It's pretty clunky in my opinion, and I'm not sure why Apple doesn't just allow straight static function variables, but this seems quite a bit cleaner than your approach.
The only work around for this that I've come up with thus far is something that looks like this:
func foo() -> Int {
struct Holder {
static var timesCalled = 0
}
return ++Holder.timesCalled;
}
It's pretty clunky in my opinion, and I'm not sure why Apple doesn't just allow straight static function variables, but this seems quite a bit cleaner than your approach.
The only work around for this that I've come up with thus far is something that looks like this:
func foo() -> Int {
struct Holder {
static var timesCalled = 0
}
return ++Holder.timesCalled;
}
It's pretty clunky in my opinion, and I'm not sure why Apple doesn't just allow straight static function variables, but this seems quite a bit cleaner than your approach.
The only work around for this that I've come up with thus far is something that looks like this:
func foo() -> Int {
struct Holder {
static var timesCalled = 0
}
return ++Holder.timesCalled;
}
It's pretty clunky in my opinion, and I'm not sure why Apple doesn't just allow straight static function variables, but this seems quite a bit cleaner than your approach.