3

Possible Duplicate:
Difference between Category and Class Extension?

I am often told that when you want to declare a variable as private you would make a nameless category on the .m file.

Is there anything inherently different in the nameless category as opposed to named categories?

What's the difference?

Community
  • 1
  • 1
user4951
  • 32,206
  • 53
  • 172
  • 282
  • possible duplicate of [Difference between Category and Class Extension?](http://stackoverflow.com/questions/3499704/difference-between-category-and-class-extension), http://stackoverflow.com/questions/7136124/, http://stackoverflow.com/questions/1052233/ – jscs Apr 18 '12 at 02:38

1 Answers1

6

What you refer to as a 'nameless category' is called a 'class extension'.

One difference is that the compiler expects that declarations in the class extension are defined in the class' @implementation block. That is, you do not declare the extension's @implementation block explicitly when it is in the same translation as the primary @implementation block. They are merged for your convenience. Consequently, the compiler may produce warnings.

Another difference is that an extension may declare properties which are synthesized (and consequently resize the type), where a regular category cannot. In addition to properties, instance variables may be declared in the class extension's @interface.

Beyond that, it's just convention.

justin
  • 104,054
  • 14
  • 179
  • 226