- #import <Foundation/Foundation.h>
- int main(int argc, const char * argv[]) {
- @autoreleasepool {
-
- NSString *str=@"AHSDALSDJKLAJSD";
- NSURL *URL=[NSURL URLWithString:@"file:///Users/mac/Desktop/123.txt"];
- bool b=[str writeToFile:URL atomically:YES encoding:NSUTF8StringEncoding error:nil];
- if (b) {
- NSLog(@"写入成功");
- }
-
- NSURL *url2=[NSURL fileURLWithPath:@"/Users/mac/Desktop/123.txt"];
-
- NSString *str2=[NSString stringWithContentsOfFile:url2 encoding:NSUTF8StringEncoding error:nil];
- NSLog(@"%@",str2);
-
- }
- return 0;
- }
复制代码
|
|