From 69f42dbb1dc76ad041bbb6c5f28d662e676af3e9 Mon Sep 17 00:00:00 2001 From: Jacob Farkas Date: Thu, 28 Mar 2019 18:41:42 -0700 Subject: [PATCH] Replace +load initializers with __attribute__((constructor)) functions (#1425) * Replace +load initializers with __attribute__((constructor)) functions * Updating the documentation for textureDidInitialize, per @nguyenhuy --- Source/ASConfigurationDelegate.h | 4 ++-- Source/ASDisplayNode.mm | 2 +- Source/Private/ASTipsController.mm | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/ASConfigurationDelegate.h b/Source/ASConfigurationDelegate.h index 127ec3eb1..fde3950cb 100644 --- a/Source/ASConfigurationDelegate.h +++ b/Source/ASConfigurationDelegate.h @@ -27,8 +27,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Texture framework initialized. This method is called synchronously * on the main thread from ASInitializeFrameworkMainThread if you defined - * AS_INITIALIZE_FRAMEWORK_MANUALLY or from the default initialization point - * (currently +load) otherwise. + * AS_INITIALIZE_FRAMEWORK_MANUALLY or otherwise from the default initialization point + * (currently a static constructor, called before main()). */ - (void)textureDidInitialize; diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index fc541178f..7bc5716de 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -284,7 +284,7 @@ + (void)initialize } #if !AS_INITIALIZE_FRAMEWORK_MANUALLY -+ (void)load +__attribute__((constructor)) static void ASLoadFrameworkInitializer(void) { ASInitializeFrameworkMainThread(); } diff --git a/Source/Private/ASTipsController.mm b/Source/Private/ASTipsController.mm index acc592130..e30a064d6 100644 --- a/Source/Private/ASTipsController.mm +++ b/Source/Private/ASTipsController.mm @@ -37,9 +37,9 @@ @implementation ASTipsController #pragma mark - Singleton -+ (void)load +__attribute__((constructor)) static void ASLoadTipsControllerNotification(void) { - [NSNotificationCenter.defaultCenter addObserver:self.shared + [NSNotificationCenter.defaultCenter addObserver:ASTipsController.shared selector:@selector(windowDidBecomeVisibleWithNotification:) name:UIWindowDidBecomeVisibleNotification object:nil];