所以我正在構建一個顫振原生插件。我有兩種方法(in xyzPlugin.m),看起來像這樣
(void)registerWithRegistrar:(nonnull NSObject<FlutterPluginRegistrar> *)registrar {
和
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
現在,我想在他們兩個之間共享實體變數。
認為。meetingView我在里面這樣初始化registerWithRegistrar
MeetingView *meetingView = [MeetingView new];
我怎樣才能在 中使用相同的handleMethodCall?
我嘗試了什么?
@implementation xyzPlugin {
MeetingView *_view;
}
然后在
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
_view = [MeetingView new];
但這會產生以下錯誤
在類方法中訪問的實體變數“_view”
uj5u.com熱心網友回復:
也許您需要一個全域變數,因此您可以使用static如下關鍵字宣告您的物件:
static MeetingView *_meetingView = ...
然后你可以在 Objective-C 的類方法之間訪問這個物件。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/426050.html
