iOS Prefix.pch best practices

后端 未结 4 939
既然无缘
既然无缘 2020-11-28 18:45

I have seen many developers that add various convenience macros to the Prefix.pch of their iOS projects.

What do (or don\'t) you recommend adding to the iOS Prefix.p

4条回答
  •  悲&欢浪女
    2020-11-28 19:36

    I agree with bbum. My take on the PCH file is that it should contain pretty much only #include or #import statements. So if you have a bunch of helpful, high-level macros, define them in something like Common.h and #import that file, as bbum suggested.

    I usually go a step further and use the PCH file to #import a file called XXCategories.h (where XX is the class naming prefix convention you use) that contains #imports for all my UIKit and Foundation class categories: NSString+XXAdditions.h, UIColor+XXAdditons.h, etc.

提交回复
热议问题