Forum > Cocoa

handler EventKit can't get it to work

<< < (2/2)

Jonas Maebe:
The issue is that the type definition for all of the C-block types in the CocoaInt headers is wrong. It's defined as Pointer, but it should be a C-block procvar type. These are records, and are passed by value rather than by reference (so just passing @cblockvar won't work).

To fix this for individual cases, you'll need to redefine the relevant methods using correct parameter types. You can do so by creating a category for the relevant class with a method that has the correct signature. I.e., in this case, something like this (untested):

--- Code: ---type
  EKEventStoreRequestAccessCompletionHandler_Fixed = reference to Procedure(granted: ObjCBOOL; error: NSError); cdecl; cblock;

  EKEventStore_FixedMethods = objccategory(EKEventStore)
    procedure requestAccessToEntityType_completion_fixed (entityType: EKEntityType; completion: EKEventStoreRequestAccessCompletionHandler_Fixed); message 'requestAccessToEntityType:completion:';
  end;

--- End code ---

And then call requestAccessToEntityType_completion_fixed instead of requestAccessToEntityType_completion.

It would be very nice if someone could take responsibility to fixing and maintaining the Cocoa headers, because the original creator hasn't done so for quite a while and never added support for blocks after the compiler got support for it. You can find the converter used to create the header translations at https://github.com/genericptr/Framework-Parser

BVale:
jonas maebe, thank you for the answer, I have tried that also... it will just rise an error as well.

my knowledge of development is not that advance... the framework-parser dont work here couse it needs php7... and  I just get php8 installed and forcing it to run on 8 doesn't work that well.



BVale:
found the solution



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type   EKEventStoreRequestAccessCompletionHandler = procedure(granted: Boolean; error: NSError) of object; cblock; cdecl;    EKEventStore = objcclass external (NSObject)     procedure requestFullAccessToEventsWithCompletion(completion: EKEventStoreRequestAccessCompletionHandler); message 'requestFullAccessToEventsWithCompletion:'; // Beachten Sie die Verwendung der message-Direktive     function calendarsForEntityType(entityType: EKEntityType): NSArray; message 'calendarsForEntityType:';         

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.RequestAccessHandler(granted: Boolean; error: NSError);begin  if granted then    //FMessage := 'Zugriff gew√§hrt'  else if Assigned(error) then    //FMessage := 'Fehler: ' + error.localizedDescription.UTF8String  else    //FMessage := 'Zugriff verweigert'; end;  procedure TForm1.Button1Click(Sender: TObject);var  store: EKEventStore;begin  store := EKEventStore.alloc.init;  store.requestFullAccessToEventsWithCompletion(RequestAccessHandler); end;   

Jonas Maebe:
You really should use ObjCBool instead of boolean, otherwise it's guaranteed to break on some platforms.

BVale:
@Jonas maebe oh yeah u are right!
thanks for the reminder.

do u have an idea how to integrate that into the eventstore.inc? so I have not to include everything from there to my working unit?...

Navigation

[0] Message Index

[*] Previous page

Go to full version