如何在iOS上编写文件?我正在尝试使用以下代码,但我做错了:
char *saves = "abcd";
NSData *data = [[NSData alloc] initWithBytes:saves length:4];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"MyFile"];
[data writeToFile:appFile atomically:YES];
Run Code Online (Sandbox Code Playgroud)
我在资源上创建了MyFile.txt.
我正在开发我的第一个iPhone应用程序.我必须每隔x秒用设备速度更新一个标签.我创建了自己的CLController,我可以获得设备速度,但我不知道是否必须使用NSTimer更新我的标签.我该怎么做?
ios ×2
iphone ×2
cllocation ×1
cocoa-touch ×1
file ×1
mapkit ×1
nsbundle ×1
nstimer ×1
overlay ×1