如何找回短信
这是我如何保存文本的代码
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:@"myFile.plist"];
NSString *savedString = _textView.text;
//NSString *saveString=_textView2.text;
[savedString writeToFile:documentTXTPath atomically:YES ];
请告诉我如何检索它。请帮我。以及如何在我的项目本身中制作plist。 谢谢。
This is code how I save text
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:@"myFile.plist"];
NSString *savedString = _textView.text;
//NSString *saveString=_textView2.text;
[savedString writeToFile:documentTXTPath atomically:YES ];
Please tell me how to retrieve it. Please help me. And how to make plist in my project itself.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
快速的方法是:
不要忘记进行错误处理。
请注意,这将阻塞主线程,直到加载整个文本文件。如果您正在处理大文件,您可能需要使用
mmap
和munmap
。顺便说一句,如果您想通过网络加载文本文件,永远不要使用
NSString stringWithContentsOfURL
(或任何一般的 *WithContentsOfURL 方法)。此方法将阻塞主线程,直到文件下载完毕。在这种情况下,请改用NSURLConnection
或ASIHTTPRequest
。The quick way would be:
Don't forget to do your error handling.
Be aware that this will block the main thread until the whole text file has been loaded. If you're dealing with large files, you may want to use
mmap
andmunmap
.As a side note, if you'll ever want to load a text file over a network, never use
NSString stringWithContentsOfURL
(or any of the *WithContentsOfURL methods in general). This method will block the main thread until the file has been downloaded. In that case, useNSURLConnection
orASIHTTPRequest
instead.您可以尝试使用
NSString
类方法stringWithContentsOfFile:
You can try using
NSString
class methodstringWithContentsOfFile:
我想,您可能想知道,如何在应用程序中处理 plist ...
这是从 plist 获取数据并写入 plist 的 SO 帖子...
如何读取 plist 数据并从中获取 int?
如何将数据写入plist
这是从中读取字典中数据的代码列表...
I think , you might want to know, how to deal with plist in application ...
Here is the SO post to get data from plist and to write to plist ...
How to read a plist data and get int from it?
How to write the data to the plist
Here is the Code to read the data in dictionary from plist...