mikecsh / mbtablegrid

An NSControl subclass which provides a spreadsheet-style table grid
45 stars 16 forks source link

Overridden property setters #6

Closed ghost closed 11 years ago

ghost commented 11 years ago

MBTableGrid overrides property setters in a category called OverriddenPropertyAccessors. When building MBTableGrid, two sets of property setters are generated: those synthesised by the compiler, and those in OverriddenPropertyAccessors. For example:

$ nm -a MBTableGrid | grep setDelegate
0000000000008640 t -[MBTableGrid setDelegate:]
0000000000008640 - 01 0000   FUN -[MBTableGrid setDelegate:]
0000000000008c70 - 01 0000   FUN -[MBTableGrid(OverriddenPropertyAccessors) setDelegate:]
0000000000008c70 t -[MBTableGrid(OverriddenPropertyAccessors) setDelegate:]

The Objective-C runtime makes no guarantee that -[MBTableGrid(OverriddenPropertyAccessors) setDelegate:] is executed when an MBTableGrid instance receives setDelegate:. In fact, which of those two methods ends up being executed is undefined. The linker issues warnings for this case:

ld: warning: instance method 'setDelegate:' in category from MBTableGrid-gdhqwpkgucazksgfoiatqlejkron/Build/Intermediates/MBTableGrid.build/Debug/MBTableGrid.build/Objects-normal/x86_64/MBTableGrid.o overrides method from class in MBTableGrid-gdhqwpkgucazksgfoiatqlejkron/Build/Intermediates/MBTableGrid.build/Debug/MBTableGrid.build/Objects-normal/x86_64/MBTableGrid.o

Furthermore, there is no need to place those methods in a category.

I suggest removing the OverriddenPropertyAccessors category entirely and moving those property setters to the main @implementation. Other categories in this project are probably unnecessary as well.

@mikecsh Let me know if you want me to submit a pull request fixing this issue.

mikecsh commented 11 years ago

Hi @bavarious, please do feel free to submit a pull request for this if you have a fix. Unfortunately, I'm a bit short of time to work on MBTableGrid at the moment. I've added you as a collaborator on this repo though, so hopefully that will be of some use until I regain some free time.