[fpc-pascal] FPC PasCocoa/Differences

Adriaan van Os fpc at microbizz.nl
Sat Mar 27 19:11:38 CET 2021

The FPC PasCocoa/Differences wiki <https://wiki.lazarus.freepascal.org/FPC_PasCocoa/Differences> 
writes about ObjC class extensions:

	"You can use regular (non-external) categories defined in the implementation of a unit instead of 
class extensions, as the effect will be the same."

However, the Apple Programming with Objective-C manual writes here 

	"Categories can be used to declare either instance methods or class methods but are not usually 
suitable for declaring additional properties."


	"The only way to add a traditional property—backed by a new instance variable—to an existing class 
is to use a class extension, as described in Class Extensions Extend the Internal Implementation."

So, the FPC PasCocoa/Differences wiki seems to ignore a crucial difference between ObjC categories 
and ObjC class extensions, namely the ability to add properties to an existing class.

Am I correct that the latter is not possible in Objective-Pascal ? So, for example, I want to add a 
pointer field to NSView and all used classes inheriting from it. I could of course subclass NSView 
and used the classes inheriting from it, but that would be rather clumsy.


Adriaan van Os

More information about the fpc-pascal mailing list