The problem I was battling yesterday reduces to a single relevant question: How do you define a type for a class method pointer?
The problem I was battling yesterday reduces to a single relevant question: How do you define a type for a class method pointer?
This does not work:
TOFunc = function(const ID: Integer; Data: string): Integer of object;
My workaround at present is not to use the class method, but to create a simple function in the unit which calls the class method. A one line wrapper. That then makes it possible to use this type:
TMyFunc = function(const ID: Integer; Data: string): Integer;
It would be much better, in the context of this requirement, to define the type for the class method. An example function is here:
TMyClassOne = class
class function Execute(const ID: Integer; Data: string): Integer;
end;
Ultimately, the delegates will be declared in a const array of records.
As written, when I attempt to call a delegate, it throws an AV.
This does not work:
TOFunc = function(const ID: Integer; Data: string): Integer of object;
My workaround at present is not to use the class method, but to create a simple function in the unit which calls the class method. A one line wrapper. That then makes it possible to use this type:
TMyFunc = function(const ID: Integer; Data: string): Integer;
It would be much better, in the context of this requirement, to define the type for the class method. An example function is here:
TMyClassOne = class
class function Execute(const ID: Integer; Data: string): Integer;
end;
Ultimately, the delegates will be declared in a const array of records.
As written, when I attempt to call a delegate, it throws an AV.
+Nicholas http://stackoverflow.com/questions/21403628/how-can-i-search-for-delphi-documentation
ReplyDeleteDavid Heffernan Nice! Thanks for that!
ReplyDeleteYou learn something new every day...
ReplyDelete