• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Yesi-悦思
"(program(computers) == *art) ? so : what" 修身岂为名传世,作事惟思利及人
博客园    首页    新随笔    联系   管理    订阅  订阅

NSString的导出

字符串的导出,写到某个文件中去

void stringExport(){

NSString *str=@"123456";

//if file not exist will not show error and it will create

//if file folder not exist will show error文件夹不存在

//if encoding not match will show error编码指定错误

NSString *path=@"/User/apple/Desktop/test.txt";

NSError *error;

//Will cover old content.

//atomically原子性。safer,123/456 if error temp will be delete and Text.txt will not be created

//

// 非原子性 only 123

//

[str writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error];

if(error){

NSLog(@"Failed, infor%@",[error localizedDescription]);//return main error infor

}else{

NSLog(@"Successful");

}

}

posted @ 2015-05-15 15:07  悦思  阅读(109)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3