iOS __attribute__((constructor))

iOS里面测试几个函数

__attribute__((constructor)) static void startup()

{

    printf("startup xxx ");

}

 

__attribute__((destructor)) static void finishup()

{

    printf("finishup xxx ");

}

 

- (void)dealloc

{

    NSLog(@"dealloc xxx");

}

 

app启动起来会先调用 constructor,即使是没有进入对应的页面

退出页面会调用dealloc

杀掉app后会调用destructor函数

 

原文地址:https://www.cnblogs.com/wxm5558/p/5927569.html