Cannot declare variable inside @interface or @protocol

前端 未结 4 1678
时光说笑
时光说笑 2021-01-31 18:19

I have an iOS app built since the beginning with an error in it. Since the source was began constructed from the template, its appdelegate.h looks like:

@interfa         


        
4条回答
  •  误落风尘
    2021-01-31 19:16

    C Global variables should be declared in .m implementation files, not in .h header files. An extern declaration can go in the .h header files, usually after the includes and outside the interface declarations.

    It's also good practice to initialize global object pointers to nil, or else they might contain a garbage object reference.

提交回复
热议问题