Array writes to Local
1. What to write
nsarray* arr = @[@ "1", @ "2", @ "3"];
2. Where to write
NSString *STR2 = [documentstr stringbyappendingpathcomponent:@ "Fuckyou.avi"];
NSLog (@ "%@", documentstr);
3. Write in
[arr writetofile:str2 Atomically:yes];
4. Finish it and get it out.
Nsarray *array = [Nsarray Arraywithcontentsoffile:path];
NSLog (@ "%@", array);
Dictionary writes to Local
Writes directly to the local time after the first write. If you write to the same file again, the previous one is overwritten.
Only one piece of data can be written at a time
If you don't want to overwrite it, read it first and then write it together.
All that can be written directly to the local must comply with the Nscoding protocol
1?? To write something
Nsdictionary *dic = @{@ "Xiao Qiang": @ "silly strong"};
2?? Where to write
NSString *STR3 = [documentstr stringbyappendingstring:@ "/ss.tet"];
3?? Write it in.
[DiC Writetofile:str3 Atomically:yes];
4?? Take it out and try it out.
Nsdictionary *DICC = [Nsdictionary Dictionarywithcontentsoffile:path];
NSLog (@ "document=====%@", documentstr);
NSLog (@ "DICC = = =%@", DICC);
Picture is written locally
NSString *str [email protected] "http://img.fs0757.com/news/2015/0901//2015090110400752.jpg";
Nsurl *url = [Nsurl urlwithstring:str];
NSData *data = [NSData Datawithcontentsofurl:url];
NSString *pathh = [Documentstr stringbyappendingstring:@ "/monkey. png"];
[Data writetofile:pathh Atomically:yes];
Uiimageview *img = [[Uiimageview alloc]initwithframe:cgrectmake (100, 100, 100, 100)];
NSData *data1 = [NSData datawithcontentsoffile:pathh];
UIImage *image = [UIImage imagewithdata:data1];
Img.image = image;
[Self.view addsubview:img];
NSLog (@ "Path = = =%@", path);
Data is written locally