资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

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文件的增删,改查-创新互联
标题路径:http://cdkjz.cn/article/ddiihj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220