取plist文件的方法

- (void) loadConfig;

{

NSString * filePath = [[NSBundle mainBundle] pathForResource:@"config" ofType:@"plist"];


if(filePath == nil)

{

self.hqfwq_Urlstr = @"http://www.hxqfhq.com:9000/";

}else {

NSMutableDictionary* dict = [ [ NSMutableDictionary alloc ] initWithContentsOfFile:filePath];

NSString * str = [self getCacheWithUrl:filePath needCacheValid:NO];

// 当读取不到 cache文件,或者读取到 cache 文件版本和 资源文件版本不一样的时候以资源文件为准. 并写入 cache文件.

if (str==nil || 

[[[str JSONValue] objectForKey:@"version"] isEqualToString:[dict objectForKey:@"version"]]==NO) {

self.configDict = dict;

[self cacheDataWithUrl:filePath data:[self.configDict JSONRepresentation]];

}else {

self.configDict = [str JSONValue];

}



NSUInteger index = [[self.configDict objectForKey:@"currServerUrl"] intValue];

[self loadConfigWithIndex:index]; 

[dict release];

}

}

你可能感兴趣的:(取plist文件的方法)