I've come across Objective-C code that declares a variable right below the @implementation line in a .m file and not in the @interface block of the .h file. It then proceeds to use it like a private ivar. I haven't been able to find documentation about declaring variables this way and would like to know the impact.
Example:
.h
@interface MyClass {
@private
int _myPrivInt1;
}
@end
.m
@implementation
int _myPrivInt2;
@end
Questions:
What is the technical difference between these two variables?
Is it the same as declaring an ivar in the .h @interface block using the @private modifier or is it more like a C global variable?
Are there any implications when declaring a variable this way?
Should it be avoided?
Is there a term for declaring variables like _myPrivInt2 that would have made my googling a bit more successful?