[fpc-devel] Small change to Objective-Pascal: overriding category methods

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Sep 22 23:44:21 CEST 2010


Hello,

Methods declared in an objccategory are now also considered to be part of the objcclass that is extended when declaring child objcclasses. This means that when you declare the same method in a child objcclass (to override it), you now have to add "override" to that declaration in the child objcclass (and you can leave out the message name). Previously, adding "override" for overridden category methods would give a compiler error stating that there was no method to override.

Reason: the next version of CocoaAll will have all the categories split off from the objcclass declarations (currently all category methods are merged into the class definitions themselves), so without this change even more existing code would break. And in the future, code would keep on breaking because the way Apple deprecates methods in Objective-C is by moving their declaration from the objcclass definition into a separate NSDeprecated category for that objcclass. Furthermore, the new way also properly indicates the way things work in practice: those methods are in fact overridden like any method that is directly declared in a parent objcclass.

Example: http://svn.freepascal.org/svn/fpc/trunk/tests/test/tobjc36.pp


Jonas


More information about the fpc-devel mailing list