I have a TPushEvent and TKinveyProvider declared on my firemonkey form
I'm trying to manually set the value of the Provider in code. I realize that by default when you drop those controls on a form the the PushEvent's Provider property is automatically set to the TKinveyProvider. However, I'm working around an apparent bug and I'd like set it later.
Am I setting the provider property correctly in this snippet?
//In my form class
//...
myPushEvents: TPushEvents;
myKinveyProvider: TKinveyProvider;
//later on in one of my procedures/methods
//...
myPushEvents.Provider := myKinveyProvider;
When I look a the value else later on after it should have been set, it still appears to be nil
.
Provider
appears to be defined as a IBackendProvider
which is an interface and I'm not sure if I have to assign it its provider differently than I would with a simple data type like an Integer or a String.
Yes, this is the right way to do it.
myPushEvents.Provider := myKinveyProvider
In this cases myPushEvents.Provider
is being assigned a reference to myKinveyProvider
. You don't have to do any special casting because myPushEvents.Provider
expects something that conforms to the IBackendProvider
interfcase, and myKinveyProvider
(a TKinveyProvider
) does.
Note: In my specific case, thanks to myPushEvents.Provider
being set as the result of a timer finishing, it was indeed still nil
.
Adding an
if (myPushEvents.Provider <> nil) then
begin
// ... use myPushEvents.Provider
end;
protected the usage of it until the value had been set properly after the timer ran.