Several common methods of storage in iOS development

Source: Internet
Author: User
<span id="Label3"></p><p><p>1. Archive Archive</p></p> <blockquote> <blockquote> <p>Preservation of data</p> <pre class="alt"><span class="lnum"> 1: </span>as <span class="kwrd"></span> String)</pre> <pre><span class="lnum"> 2: </span> println (<span class="str">"save result \ (result)"</span>)</pre> <style type="text/css">.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }</style> </blockquote> </blockquote><p><p>Read the Data:</p></p> <blockquote> <pre class="alt"><pre class="alt"><span class="lnum"> 1: </span>var t:[contact]?</pre></pre> <pre><pre><span class="lnum"> 2: </span>as <span class="kwrd"></span> String)</pre></pre> <pre class="alt"><pre class="alt"><span class="lnum"> 3: </span> <span class="kwrd">if</span> any = = Nil {</pre></pre> <pre><pre><span class="lnum"> 4: </span> t = [contact] ()</pre></pre> <pre class="alt"><pre class="alt"><span class="lnum"> 5: </span> }<span class="kwrd">else</span>{</pre></pre> <pre><pre><span class="lnum"> 6: </span> println (<span class="str">"read success"</span>)</pre></pre> <pre class="alt"><pre class="alt"><span class="lnum"> 7: </span>as <span class="kwrd"></span>? [contact]</pre></pre> <pre><pre><span class="lnum"> 8: </span> }</pre></pre> <style type="text/css"><style type="text/css">.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }</style></style> </blockquote><p><p>The init with Coder method and Encodewithcoder method need to be implemented in the model</p></p><p><p></p></p><p><p></p></p><p><p></p></p><p><p>2. User Default</p></p><p><p></p></p><p><p>3. plist Storage</p></p><p><p></p></p> <pre class="alt"><pre class="alt"><span class="lnum"> 1: </span> [datadic setvalue:eachdarray forkey:<span class="str">"key"</span>];</pre></pre> <pre><pre><span class="lnum"> 2: </span>[datadic writetofile:filename atomically:yes];</pre></pre><style type="text/css"><style type="text/css">.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }</style></style><p><p>Several common methods of storage in iOS development</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.