Swift reads app version information
There is time we need to read the app version information such as configuration information, so we can use the method: Nsbundle.mainbundle (). Infodictionary to get
Example:
Swift
Let infodictionary = Nsbundle.mainbundle (). infodictionary
Let shortversion = infodictionary! ["Cfbundleshortversionstring"]
Print (shortversion!)
PCH file
PCH file name:
Generally named after the project name, that is, what the project name is, PCH file also called what name.
PCH principle:
The contents of the PCH file are shared by all files in the project.
PCH Tips:
1.pch need to compile in advance, in the engineering file, find build Setting, select the All option, found under the Apple LLVM 1.7–language collection: Precompile Prefix Header set to Yes, then Prefix The absolute path to write the PCH file in the Header option,
2. Find the Swift Compiler–code Generation collection from which to configure the Objectie-c Bridge file: objective-c bridging Header, write the same PCH file path
3. Press Command+b to compile in Xcode
PCH file function:
Swift
/*
Preferred to determine whether there is currently a C file, if there is C does not import OC syntax
Each OC file header will be defined by default __OBJC__ this macro
*/
#ifdef __objc__
/**
1. Store some common macros
*/
#define Persimmon "Mr.cong"
/**
2. Store some common header files
*/
#import "Uiimage+test.h"
/**
3. Customize some debugging nslog (output log)
... Represents a variable parameter inside a macro
__VA_ARGS__ represents a variable parameter within a function
*/
#ifdef DEBUG
#define TLOG (...) NSLog (__va_args__)
#else
#define TLOG (...)
#endif
#endif
PCH drawbacks;
1. Need to compile ahead of time
2. Need to make some judgments to determine whether there is currently a C file, if there is C does not import OC syntax