I would like to know what's the difference between declaring my instance variables like this:
// inside the implementation file (.m)
@interface MyCustomObject()
{
id _myIvar;
}
@end
@implementation MyCustomObject
...
@end
And like this:
// inside the implementation file (.m)
@implementation MyCustomObject{
id _myIvar;
}
...
@end
From the point of view of the USE, there is not difference.
From the point of view of the declaration, the first one is a Category
:
@interface MyCustomObject()
{
}
so if you have a variable with the same name in the header file, your implementation file will see this one, but other classes whose import that header file, will see the other one.
This mechanism can be really useful to assign different attributes or properties to the same var, but differencing the exposed var, from the private internal var.