[ios]代码库
//获取文件路径
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"fileName"];
//待写入的数据
NSString *temp = @”Welcome to blog.iosxcode4.com”;
int data0 = 100000;
float data1 = 23.45f;
//创建数据缓冲
NSMutableData *writer = [[NSMutableData alloc] init];
//将字符串添加到缓冲中
[writer appendData:[temp dataUsingEncoding:NSUTF8StringEncoding]];
//将其他数据添加到缓冲中
[writer appendBytes:&data0 length:sizeof(data0)];
[writer appendBytes:&data1 length:sizeof(data1)];
//将缓冲的数据写入到文件中
[writer writeToFile:path atomically:YES];
[writer release];
by: 发表于:2017-10-25 10:44:56 顶(0) | 踩(0) 回复
??
回复评论