common parameters in iphone
How can I define common parameters in iPhone to use everywhere in different c开发者_运维百科lasses.
Write and retrieve your parameters from a .plist file:
NSString *filePath = @"Parameters.plist";
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
NSString *value = [plistDict objectForKey:@"parameterName"];
You can also add common definitions class file (e.g. AppConstansts.h
), fill it with defines (e.g. #define CELL_HEIGHT 44.0
) and add an import line (#import "AppConstansts.h"
) in <Your project name>_Prefix.pch
file that is usually located under "Other Sources" group in the project.
After doing it CELL_HEIGHT will be accessible from all your source files...
精彩评论