大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

iOSplist文件的增删,改查-创新互联

//路径

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册雅安服务器托管、营销软件、网站建设、河口网站维护、网站推广。

+ (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;

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文名称:iOSplist文件的增删,改查-创新互联
分享URL:http://dzwzjz.com/article/ddiihj.html
在线咨询
服务热线
服务热线:028-86922220
TOP