Objective-C - iVar Scoped Method Variables?
I was messing around in Objective-C earlier, and I ran into a quite common situation: I had a class, which was not a singleton, that needed a variable shared between method calls, like static , but each instance needed it's own variable. However, this variable only needed to be used in one particular method, we'll call it -foo . What I'd love to do, is have a macro, let's call it ivar , which lets me do the following: @implementation MyClass -(foo) { ivar int someVal = 10; // default value, ivar scoped variable. } -(bar) { someVal = 5; // error, outside of `foo`'s scope. } @end How the