Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Class Methods | Properties | List of all members
FlutterAppLifecycleRegistrar Class Reference

#include <FlutterAppLifecycleDelegate.h>

Inheritance diagram for FlutterAppLifecycleRegistrar:
<FlutterAppLifecycleDelegate>

Instance Methods

(void) - addDelegate:
 
(void) - removeDelegate:
 
(void) - addObserverFor:selector: [implementation]
 
(instancetype) - init [implementation]
 
(void) - dealloc [implementation]
 
- Instance Methods inherited from <FlutterAppLifecycleDelegate>
(void) - handleWillFinishLaunching:
 
(void) - handleDidFinishLaunching:
 
(void) - handleWillBecomeActive:
 
(void) - handleDidBecomeActive:
 
(void) - handleWillResignActive:
 
(void) - handleDidResignActive:
 
(void) - handleWillHide:
 
(void) - handleDidHide:
 
(void) - handleWillUnhide:
 
(void) - handleDidUnhide:
 
(void) - handleDidChangeScreenParameters:
 
(void) - handleDidChangeOcclusionState:
 
(BOOL- handleOpenURLs:
 
(void) - handleWillTerminate:
 

Class Methods

(static BOOL+ IsPowerOfTwo [implementation]
 

Properties

NSPointerArray * delegates [implementation]
 

Detailed Description

Propagates NSAppDelegate callbacks to registered delegates.

Definition at line 126 of file FlutterAppLifecycleDelegate.h.

Method Documentation

◆ addDelegate:

- (void) addDelegate: (NSObject<FlutterAppLifecycleDelegate>*)  delegate

Registers delegate to receive lifecycle callbacks via this FlutterAppLifecycleDelegate as long as it is alive.

delegate will only be referenced weakly.

Definition at line 72 of file FlutterAppLifecycleDelegate.mm.

76 :(NSObject<FlutterAppLifecycleDelegate>*)delegate {
77 [_delegates addPointer:(__bridge void*)delegate];
79 [_delegates compact];
80 }
81}
NSPointerArray * _delegates
int count

◆ addObserverFor:selector:

- (void) addObserverFor: (NSString*)  name
selector: (SEL)  selector 
implementation

Definition at line 1 of file FlutterAppLifecycleDelegate.mm.

20 :(NSString*)name selector:(SEL)selector {
21 [[NSNotificationCenter defaultCenter] addObserver:self selector:selector name:name object:nil];
22 __block NSObject* blockSelf = self;
23 dispatch_block_t unsubscribe = ^{
24 [[NSNotificationCenter defaultCenter] removeObserver:blockSelf name:name object:nil];
25 };
26 [_notificationUnsubscribers addObject:[unsubscribe copy]];
27}
const char * name
Definition fuchsia.cc:50

◆ dealloc

- (void) dealloc
implementation

Definition at line 1 of file FlutterAppLifecycleDelegate.mm.

63 {
64 for (dispatch_block_t unsubscribe in _notificationUnsubscribers) {
65 unsubscribe();
66 }
67 [_notificationUnsubscribers removeAllObjects];
68 _delegates = nil;
69 _notificationUnsubscribers = nil;
70}

◆ init

- (instancetype) init
implementation

Definition at line 1 of file FlutterAppLifecycleDelegate.mm.

29 {
30 if (self = [super init]) {
31 _notificationUnsubscribers = [[NSMutableArray alloc] init];
32
33// Using a macro to avoid errors where the notification doesn't match the
34// selector.
35#ifdef OBSERVE_NOTIFICATION
36#error OBSERVE_NOTIFICATION ALREADY DEFINED!
37#else
38#define OBSERVE_NOTIFICATION(SELECTOR) \
39 [self addObserverFor:NSApplication##SELECTOR##Notification selector:@selector(handle##SELECTOR:)]
40#endif
41
42 OBSERVE_NOTIFICATION(WillFinishLaunching);
43 OBSERVE_NOTIFICATION(DidFinishLaunching);
44 OBSERVE_NOTIFICATION(WillBecomeActive);
45 OBSERVE_NOTIFICATION(DidBecomeActive);
46 OBSERVE_NOTIFICATION(WillResignActive);
47 OBSERVE_NOTIFICATION(DidResignActive);
48 OBSERVE_NOTIFICATION(WillTerminate);
49 OBSERVE_NOTIFICATION(WillHide);
50 OBSERVE_NOTIFICATION(DidHide);
51 OBSERVE_NOTIFICATION(WillUnhide);
52 OBSERVE_NOTIFICATION(DidUnhide);
53 OBSERVE_NOTIFICATION(DidChangeScreenParameters);
54 OBSERVE_NOTIFICATION(DidChangeOcclusionState);
55
56#undef OBSERVE_NOTIFICATION
57
58 _delegates = [NSPointerArray weakObjectsPointerArray];
59 }
60 return self;
61}
#define OBSERVE_NOTIFICATION(SELECTOR)

◆ IsPowerOfTwo

+ (static BOOL) IsPowerOfTwo (NSUInteger)  x
implementation

Definition at line 72 of file FlutterAppLifecycleDelegate.mm.

72 {
73 return x != 0 && (x & (x - 1)) == 0;
74}
double x

◆ removeDelegate:

- (void) removeDelegate: (NSObject<FlutterAppLifecycleDelegate>*)  delegate

Unregisters delegate so that it will no longer receive life cycle callbacks via this FlutterAppLifecycleDelegate.

delegate will only be referenced weakly.

Definition at line 72 of file FlutterAppLifecycleDelegate.mm.

83 :(NSObject<FlutterAppLifecycleDelegate>*)delegate {
84 NSUInteger index = [[_delegates allObjects] indexOfObject:delegate];
85 if (index != NSNotFound) {
86 [_delegates removePointerAtIndex:index];
87 }
88}

Property Documentation

◆ delegates

- (NSPointerArray*) delegates
readwritenonatomicstrongimplementation

Registered delegates. Exposed to allow FlutterAppDelegate to share the delegate list for handling non-notification delegation.

Provided by category FlutterAppLifecycleRegistrar().

Definition at line 15 of file FlutterAppLifecycleDelegate_Internal.h.


The documentation for this class was generated from the following files: