-(void)writeToFile:(NSData *)data
{
NSString *filePath=[NSString stringWithFormat:@"%@",_fileName];
if([[NSFileManager defaultManager] fileExistsAtPath:filePath] == NO)
{
[[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil];
}
FILE *file = fopen([_fileName UTF8String], [@"ab+" UTF8String]);
if(file != NULL)
{
fseek(file, 0, SEEK_END);
int readSize = [data length];
fwrite((const void *)[data bytes], readSize, 1, file);
fclose(file);
}
else
{
NSLog(@"open %@ error!", _fileName);
}
}这是直接写文件的一种方式,其他逻辑自己处理下。
{
NSString *filePath=[NSString stringWithFormat:@"%@",_fileName];
if([[NSFileManager defaultManager] fileExistsAtPath:filePath] == NO)
{
[[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil];
}
FILE *file = fopen([_fileName UTF8String], [@"ab+" UTF8String]);
if(file != NULL)
{
fseek(file, 0, SEEK_END);
int readSize = [data length];
fwrite((const void *)[data bytes], readSize, 1, file);
fclose(file);
}
else
{
NSLog(@"open %@ error!", _fileName);
}
}这是直接写文件的一种方式,其他逻辑自己处理下。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货