存储失败的坑

+ (NSString *)getAppDocumentDir
{
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                NSUserDomainMask,
                                                YES) objectAtIndex:0];
    
}
+ (void)saveListenDataWithFileName:(NSString *)fileName
                           AndData:(NSData *)data
                    AndFinishBlock:(void(^)(NSString *path,bool success))block;{
     NSString *path = [NSString stringWithFormat:@"kapEpUser%@ListenData%@sound.%@",[KapUserAccountStore loadActiveUserID],fileName,KapRecordFileUtil.MusicType];
    NSString *finallyPath = [self theAppDocuPathWithPath:path];
    //    bool bo = [data writeToFile:path atomically:YES];
    NSError *error = nil;
    BOOL bo =  [data writeToFile:finallyPath options:NSDataWritingAtomic error:&error];
    NSLog(@"%@,error=%@",error?@"写入失败":@"写入成功",error);
    if (block) {
        block(path,bo);
    }
}
+ (NSString *)theAppDocuPathWithPath:(NSString *)path{
    NSString *documentpathString = [KapAppUtil getAppDocumentDir];
    return [NSString stringWithFormat:@"%@/%@",documentpathString,path];
}

存的时候不要将documentpathString 也拼入path, documentpathString是会变得~~~`

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,751评论 25 709
  • 仓敷的美观地区,平时饭店基本都不开门,或许只在节假日营业。所以吃饭还是走出来,往车站方向。 日本的每个城市都有这样...
    wingfish阅读 223评论 0 2
  • 文/唐宋 我的缱绻恣睢 度过寂寞如雪的年少 冲动偏激的语言 在口舌中伤痛了谁 我把愤怒留下,孤独留下 抚慰我的悲催...
    唐宋a阅读 162评论 1 3
  • 本来以为是直白而平淡的一章,不料不仅花了比较长的时间来读,而且读的过程中来回翻看,以致一度认为过了一年又老了一岁以...
    大笑的篷蒿人阅读 501评论 1 1
  • 夜渐渐静了,转眼间又是一年冬季,似乎夏日过后跳过秋,似乎落叶还未曾见到树就已光秃秃一片,寒风中的摇晃,少了夏日摆动...
    凌悦沫心阅读 263评论 0 1