简体   繁体   中英

Declaring global variables in Objective-C

I have a question about variable declaration in Objective-C

in case of global variable what is the difference between declaration in the .m file and .h file?

should i declare property for each variable in .h file?

If you put it in the .h file, then things that include the .h file can access it directly. If you want that, do that. Otherwise put it in the .m.

Declaring global variables in .h and in .m has the same effect just like declaring global variable in .h and in .c. However, it is a good practice to declare it in your .h.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM