//路径
创新互联建站网站建设提供从项目策划、软件开发,软件安全维护、网站优化(SEO)、网站分析、效果评估等整套的建站服务,主营业务为成都网站建设、成都做网站,app软件开发公司以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。创新互联建站深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
+ (NSString *)cretableName
{
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [path objectAtIndex:0];
//指定新建文件夹路径
NSString *p_w_picpathDocPath = [documentPath stringByAppendingPathComponent:[NSString stringWithFormat:@"setPlace.plist"]];
return p_w_picpathDocPath;
}
//添加
+ (void)addPlaceWrite:(NSDictionary *)dict anCity:(NSString *)cityName
{
NSString *filePath = [self cretableName];
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];
if(nil == dic)
{
dic = [NSMutableDictionary dictionaryWithCapacity:0];
}
NSMutableArray *dataArry = [dic valueForKey:cityName];
if(nil == dataArry)
{
dataArry = [NSMutableArray arrayWithCapacity:0];
}
if (0 == dataArry.count)
{
[dataArry addObject:dict];
}
else
{
[dataArry addObject:dict];
}
[dic setValue:dataArry forKey:cityName];
[dic writeToFile:filePath atomically:YES];
}
//所有
+ (NSArray *)allPlaceData:(NSString *)cityName
{
NSString *filePath = [self cretableName];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:filePath];
NSArray *aray = dict[cityName];
return aray;
}
//删除
+ (void)deletePlaceData:(NSInteger)index anCity:(NSString *)cityName
{
NSString *filePath = [self cretableName];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:filePath];
NSMutableArray *arry = dict[cityName];
[arry removeObjectAtIndex:index];
[dict setValue:arry forKey:cityName];
[dict writeToFile:filePath atomically:YES];
}
//修改
+ (void)modifyPlaceData:(NSDictionary *)dic anPlace:(NSInteger)index anCity:(NSString *)cityName
{
NSString *filePath = [self cretableName];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:filePath];
NSMutableArray *arry = dict[cityName];
[arry removeObjectAtIndex:index];
[arry insertObject:dic atIndex:index];
[dict setValue:arry forKey:cityName];
[dict writeToFile:filePath atomically:YES];
}
//查询
+ (BOOL)allCity:(NSString *)anCity
{
BOOL isBlean = NO;
NSString *filePath = [self cretableCityName];
NSArray *arry = [NSArray arrayWithContentsOfFile:filePath];
for(NSString *city in arry)
{
if([anCity isEqualToString:city])
{
isBlean = YES;
break;
}
}
return isBlean;
}