You can declare as many class extensions as you want. Each can contain instance variables and methods. As long as the compiler has seen all of the class extensions before it sees the @implementation
of the class, it will work.
You should have one source file (with extension .m
or .mm
) that contains the @implementation
of your class. That source file needs to contain all of the class extensions before the @implementation
, so if you put your extensions in .h
files, you need to include those .h
files in that .m
file.
UPDATE
To explicitly answer the question in your update: Yes. You can use two class extensions (anonymous categories) in the same file. Your class will contain the instance variables declared in both extensions, as long as the compiler sees both extensions in the same translation unit as the @implementation
of the class.