Iphone 将用户数据传输到我的服务器上的.csv文件
我喜欢将用户统计信息添加到我的应用程序中。 我喜欢将iOS版本和iDevice模型传输到服务器上的.csv文件中。我知道如何获取iOS版本和型号名称,但不知道如何将数据写入.csv文件 获取iOS版本:Iphone 将用户数据传输到我的服务器上的.csv文件,iphone,xcode,ipad,csv,Iphone,Xcode,Ipad,Csv,我喜欢将用户统计信息添加到我的应用程序中。 我喜欢将iOS版本和iDevice模型传输到服务器上的.csv文件中。我知道如何获取iOS版本和型号名称,但不知道如何将数据写入.csv文件 获取iOS版本:[UIDevice currentDevice]。系统版本 获取型号名称:[UIDevice currentDevice]。模型 是否有人知道如何将iOS系统版本写入csv文件,如下所示: iPhone,6.1 iPad,5.1 iPod,4.3 这是我现在使用的代码,但字符串尚未写入.csv文件
[UIDevice currentDevice]。系统版本代码>
获取型号名称:[UIDevice currentDevice]。模型代码>
是否有人知道如何将iOS系统版本写入csv文件,如下所示:
iPhone,6.1
iPad,5.1
iPod,4.3
这是我现在使用的代码,但字符串尚未写入.csv文件:
NSString *userinfopath = @"http://idoodler.de/userdata.csv";
NSURL *userinfo = [NSURL URLWithString:userinfopath];
if (![[NSFileManager defaultManager] fileExistsAtPath:userinfopath]) {
[[NSFileManager defaultManager] createFileAtPath: userinfopath contents:nil attributes:nil];
NSLog(@"Route creato");
}
NSMutableString *writeString = [NSMutableString stringWithFormat:@"%@ ,%@",[UIDevice currentDevice]. model,[UIDevice currentDevice]. systemVersion];
NSLog(@"writeString :%@",writeString);
NSFileHandle *handle;
handle = [NSFileHandle fileHandleForWritingAtPath: userinfopath ];
//say to handle where's the file fo write
[handle truncateFileAtOffset:[handle seekToEndOfFile]];
//position handle cursor to the end of file
[handle writeData:[writeString dataUsingEncoding:NSUTF8StringEncoding]];
使用此代码
- (IBAction)saveAsFileAction:(id)sender {
if (![[NSFileManager defaultManager] fileExistsAtPath:[self dataFilePath]]) {
[[NSFileManager defaultManager] createFileAtPath: [self dataFilePath] contents:nil attributes:nil];
NSLog(@"Route creato");
}
NSMutableString *writeString = [NSMutableString stringWithFormat:@"%@ ,%@",[UIDevice currentDevice]. model,[UIDevice currentDevice]. systemVersion];
NSLog(@"writeString :%@",writeString);
NSFileHandle *handle;
handle = [NSFileHandle fileHandleForWritingAtPath: [self dataFilePath] ];
//say to handle where's the file fo write
[handle truncateFileAtOffset:[handle seekToEndOfFile]];
//position handle cursor to the end of file
[handle writeData:[writeString dataUsingEncoding:NSUTF8StringEncoding]];
}
我的文件存储在我的服务器上,我必须在哪里用URL替换fileparth?