tag:blogger.com,1999:blog-61689465469894982152024-02-20T23:26:08.584-08:00iOS App Solutionsshoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-6168946546989498215.post-55123065622373573472024-01-25T10:25:00.000-08:002024-01-25T10:25:53.186-08:00Top 5 problems you will face if you continue using Storyboards in your projects!<p><br /></p><div><span style="background-color: white; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px;">1. Merge Conflicts: Frequent complex conflicts when multiple developers work on the same storyboard.</span><div><br style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px; line-height: inherit !important;" /><span style="background-color: white; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px;">2. Difficult Code Review: Reviewing changes in XML-based storyboards is more complicated than in code.</span></div><div><br style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px; line-height: inherit !important;" /><span style="background-color: white; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px;">3. Performance Overhead: Slower load times with large and complex storyboards.</span></div><div><br style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px; line-height: inherit !important;" /><span style="background-color: white; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px;"> 4. Preview Limitations: Inaccurate UI representation on different devices, needing extra adjustments.</span></div><div><br style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px; line-height: inherit !important;" /><span style="background-color: white; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 14px;"> 5. Limited Reusability: Storyboard UI components are less reusable than programmatically created ones.</span></div></div>shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-68602775094596492192022-01-16T10:58:00.002-08:002022-01-16T11:02:17.965-08:00What is @State in SwiftUI ?<p style="text-align: left;"><span style="font-family: helvetica; font-size: medium;"><span style="background-color: white;">The </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">@State</code><span style="background-color: white;"> keyword is a </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">@propertyWrapper</code><span style="background-color: white;">, a feature just recently introduced in Swift 5.1</span> </span></p><p style="text-align: left;"></p><ul style="text-align: left;"><li><span style="font-family: helvetica; font-size: medium;"><span style="background-color: white;">State is a value or a set of values, that can change over time, and that affects a view’s behaviour, content, or layout. You use property with the @State attribute to add a state to a view.</span></span></li></ul><p></p><p style="text-align: left;"><span style="font-family: helvetica; font-size: medium;"><span style="background-color: white;"><br /></span></span></p><p style="text-align: left;"></p><ul style="text-align: left;"><li><span style="font-family: helvetica; font-size: medium;"><span style="background-color: white;">when you initialize a property that's marked </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">@State</code><span style="background-color: white;">, you're not actually creating your own variable, but rather prompting </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">SwiftUI</code><span style="background-color: white;"> to create </span><em style="background-color: white; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"something"</em><span style="background-color: white;"> in the background that stores what you set and monitors it from now on! Your </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">@State var</code><span style="background-color: white;"> just acts as a </span><strong style="background-color: white; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">delegate to access this wrapper</strong><span style="background-color: white;">.</span></span></li></ul><div><br /></div><div><ul style="text-align: left;"><li><span style="font-family: helvetica; font-size: medium;"><span style="background-color: white;">Every time your </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">@State</code><span style="background-color: white;"> variable is </span><strong style="background-color: white; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">written</strong><span style="background-color: white;">, </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">SwiftUI</code><span style="background-color: white;"> will know as it is monitoring it. It will also know whether the </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">@State</code><span style="background-color: white;"> variable was </span><strong style="background-color: white; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">read</strong><span style="background-color: white;"> from the </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">View</code><span style="background-color: white;">'s </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">body</code><span style="background-color: white;">. Using this information, it will be able to </span><strong style="background-color: white; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">recompute any <code style="background-color: var(--black-075); border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">View</code></strong><span style="background-color: white;"> having referenced a </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">@State</code><span style="background-color: white;"> variable in its </span><code style="border-radius: 3px; border: 0px; box-sizing: inherit; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 2px 4px; vertical-align: baseline; white-space: pre-wrap;">body</code><span style="background-color: white;"> after a change to this variable.</span></span></li></ul><div><span style="font-family: helvetica; font-size: medium;"><br /></span></div></div><div><span style="font-family: helvetica; font-size: medium;">Code Example:-</span></div><div><pre class="lang-swift s-code-block" style="border-radius: 5px; border: 0px; box-sizing: inherit; color: var(--highlight-color); font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.30769; margin-bottom: calc(var(--s-prose-spacing) + 0.4em); margin-top: 0px; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 12px; vertical-align: baseline; width: auto;"><code class="hljs language-swift" style="border: 0px; box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span style="font-family: helvetica; font-size: medium;"> <span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">import</span> SwiftUI
<span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">struct</span> <span class="hljs-title class_" style="border: 0px; box-sizing: inherit; color: var(--highlight-literal); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">ContentView</span>: <span class="hljs-title class_" style="border: 0px; box-sizing: inherit; color: var(--highlight-literal); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">View</span> {
<span class="hljs-meta" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">@State</span> <span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">var</span> counter <span class="hljs-operator" style="border: 0px; box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span> <span class="hljs-number" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">0</span>
<span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">var</span> body: <span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">some</span> <span class="hljs-type" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">View</span> {
<span class="hljs-built_in" style="border: 0px; box-sizing: inherit; color: var(--highlight-literal); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">print</span>(<span class="hljs-string" style="border: 0px; box-sizing: inherit; color: var(--highlight-variable); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"ContentView"</span>)
<span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">return</span> <span class="hljs-type" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">VStack</span> {
<span class="hljs-type" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Button</span>(<span class="hljs-string" style="border: 0px; box-sizing: inherit; color: var(--highlight-variable); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Tap me!"</span>) { <span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">self</span>.counter <span class="hljs-operator" style="border: 0px; box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">+=</span> <span class="hljs-number" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">1</span> }
<span class="hljs-type" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">LabelView</span>(number: counter)
}
}
}</span></code></pre><pre class="lang-swift s-code-block" style="border-radius: 5px; border: 0px; box-sizing: inherit; color: var(--highlight-color); font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.30769; margin-bottom: calc(var(--s-prose-spacing) + 0.4em); margin-top: 0px; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 12px; vertical-align: baseline; width: auto;"><code class="hljs language-swift" style="border: 0px; box-sizing: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span style="font-family: helvetica; font-size: medium;">//Label created
<span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">struct</span> <span class="hljs-title class_" style="border: 0px; box-sizing: inherit; color: var(--highlight-literal); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">LabelView</span>: <span class="hljs-title class_" style="border: 0px; box-sizing: inherit; color: var(--highlight-literal); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">View</span> {
<span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">let</span> number: <span class="hljs-type" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Int</span>
<span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">var</span> body: <span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">some</span> <span class="hljs-type" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">View</span> {
<span class="hljs-built_in" style="border: 0px; box-sizing: inherit; color: var(--highlight-literal); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">print</span>(<span class="hljs-string" style="border: 0px; box-sizing: inherit; color: var(--highlight-variable); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"LabelView"</span>)
<span class="hljs-keyword" style="border: 0px; box-sizing: inherit; color: var(--highlight-keyword); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">return</span> <span class="hljs-type" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Group</span> {
<span class="hljs-type" style="border: 0px; box-sizing: inherit; color: var(--highlight-namespace); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Text</span>(<span class="hljs-string" style="border: 0px; box-sizing: inherit; color: var(--highlight-variable); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"You've tapped <span class="hljs-subst" style="border: 0px; box-sizing: inherit; color: var(--highlight-color); font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">\(number)</span> times"</span>)
}
}
}</span></code></pre></div><p></p><p style="text-align: left;"><span style="font-family: helvetica; font-size: medium;"><span style="background-color: white;"><br /></span></span></p><p style="text-align: left;"><span style="font-family: helvetica; font-size: medium;"><span style="background-color: white;"><br /></span></span></p><p style="text-align: left;"><span style="font-family: helvetica;"><span style="background-color: white; color: #525960; font-size: 15px;"><br /></span></span></p><p style="text-align: left;"><span style="font-family: helvetica;"><span style="background-color: white; color: #525960; font-size: 15px;"><br /></span></span></p>shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-49311442580748010232021-05-12T06:08:00.000-07:002021-05-12T06:08:26.933-07:00Automated Deployment with Fastlane on iOS<p><span style="font-family: times;"> <span style="background-color: white; color: #08090a; font-size: 20px;">As iOS developers, we’ve all experienced the satisfying feeling of finally finishing coding an app and being excited to share it with users. Prior to users enjoying the app, there is only one more thing left to do- release the app to the App Store! Surely, you think it shouldn’t take longer than a few minutes of your time?</span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Oh, you’re completely wrong.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">In order to reach that step, the following is needed:</span></p><ul style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Ensure you have the right certificates and provisioning profiles in place.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Create a variety of screenshots of the app.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;"><br /></span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Build the app.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Upload the app to App Store Connect.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Log in to App Store Connect, input the correct metadata and inspect the upload.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Submit the app for review and wait.</span></li></ul><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">These steps are just one approach to deploying your app as there are many more aspects that should be considered, such as dealing with build/version numbers, running tests, uploading beta releases etc.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Why is this so difficult?</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Well actually, it used to be difficult but thanks to Fastlane, all of the mentioned steps above can be automated. Continue reading this blog to find out how Fastlane can help you!</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">This blog will introduce Fastlane, the advantages it provides and present concrete scenarios showing how it automates the deployment of an application. The following examples of automation will be covered:</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><ul style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">The creation of an app</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Generation of certificates and provisioning profiles</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Deployment to Testflight</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Deployment to App Store</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;"><br /></span></li></ul><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The focus and examples used in this blog will be for iOS. However, the same principles (and in many cases the same commands) apply for Android as well.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Important note: in order to use Fastlane for iOS, you need to have a paid Apple Developer Account.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><h3 style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 1.25em; font-weight: var(--fw-bold); line-height: var(--lh-tight); margin: calc(var(--content-rhythm) / 2) 0; padding: 0px;"><span style="font-family: times;"><a href="https://dev.to/rubicon_dev/automated-deployment-with-fastlane-on-ios-218p#what-is-fastlane" name="what-is-fastlane" style="box-sizing: border-box;"></a>What is Fastlane?</span></h3><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Before moving on to how to operate Fastlane, it is important to know what it is and how to set it up properly.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><h4 style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; font-weight: var(--fw-bold); line-height: var(--lh-tight); margin: calc(var(--content-rhythm) / 2) 0; padding: 0px;"><span style="font-family: times;"><a href="https://dev.to/rubicon_dev/automated-deployment-with-fastlane-on-ios-218p#fastlane-features" name="fastlane-features" style="box-sizing: border-box;"></a>Fastlane Features</span></h4><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Fastlane is a tool that helps automate the development and release process for mobile apps.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">It’s main features include:</span></p><ul style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Automated generation of screenshots</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Beta deployment</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">App Store deployment</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Code signing</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Setting Up Fastlane</span></li></ul><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Follow these steps, taken from Fastlane’s official documentation, in order to properly setup Fastlane.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><ol style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Install latest Xcode command line tools</span></li></ol><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;">xcode-select --install</span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><ol style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Install Fastlane</span></li></ol><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="background-color: white; font-family: times; font-size: medium;"># Using RubyGems
gem install fastlane -NV
</span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white;"><span style="font-size: medium;"># Alternatively using Homebrew
brew cask install fastlane</span></span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><ol style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Navigate to project and run</span></li></ol><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white;"><span style="font-size: medium;">fastlane init</span></span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><h4 style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; font-weight: var(--fw-bold); line-height: var(--lh-tight); margin: calc(var(--content-rhythm) / 2) 0; padding: 0px;"><span style="font-family: times;"><a href="https://dev.to/rubicon_dev/automated-deployment-with-fastlane-on-ios-218p#appfile-and-fastfile" name="appfile-and-fastfile" style="box-sizing: border-box;"></a>Appfile and Fastfile</span></h4><div><span style="font-family: times;"><br /></span></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">After running fastlane init, Fastlane automatically creates a new folder within the project called ‘Fastlane’. This folder contains two files: Appfile and Fastfile which are used to help automate the deployment process.<br style="box-sizing: border-box;" /><a class="article-body-image-wrapper" href="https://res.cloudinary.com/practicaldev/image/fetch/s--BnnJ7j9w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sift4po7l29541hjsxue.png" style="box-sizing: border-box; cursor: zoom-in;"><img alt="Alt Text" loading="lazy" src="https://res.cloudinary.com/practicaldev/image/fetch/s--BnnJ7j9w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sift4po7l29541hjsxue.png" style="border-radius: var(--radius); box-sizing: border-box; display: block; height: auto; margin: var(--content-rhythm) auto; max-height: calc(50vh + 180px); max-width: 100%;" /></a></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="box-sizing: border-box; font-weight: bolder;"><span style="font-family: times;">Illustration 1: Fastlane folder structure</span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The Appfile contains information about the developer and the app, such as the developer Apple email and the app ID of the application. The Fastfile contains different lanes, written in Ruby, which represent distinct workflows, or in other words, different automation tasks. We can create and customize these, however we'd like. For example, a lane can automate releases to Testflight or deployments to the App Store. The Fastfile is the file where developers spend the most time when it comes to Fastlane.</span></p><h4 style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; font-weight: var(--fw-bold); line-height: var(--lh-tight); margin: calc(var(--content-rhythm) / 2) 0; padding: 0px;"><span style="font-family: times;"><a href="https://dev.to/rubicon_dev/automated-deployment-with-fastlane-on-ios-218p#using-fastlane" name="using-fastlane" style="box-sizing: border-box;"></a>Using Fastlane</span></h4><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Now let’s look at some examples of how to automate tasks using Fastlane.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="box-sizing: border-box; font-weight: bolder;"><span style="font-family: times;">Our First Fastfile Lane: App Creation</span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">In order to successfully upload a new build to the App Store, we first have to create the app on App Store Connect and on the Apple Developer Portal. Although this process is not too complicated, it is still a bit tedious to complete. Therefore, this is a good starting point for automation with Fastlane.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">First, open the Appfile and input a few parameters:<br style="box-sizing: border-box;" /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white;"><span style="font-size: medium;">app_identifier '[[YOUR APP IDENTIFIER]]' # The bundle identifier of the app
apple_id '[[YOUR APPLE EMAIL]]' # Apple email address
team_id '[[YOU TEAM ID]]' # Team ID from the Developer Portal
itc_team_id '[[YOUR ITC TEAM ID]]' # ID from the App Store Connect team</span></span><span style="background-color: rgba(0, 0, 0, 0.1); color: rgba(0, 0, 0, 0); font-size: 1em;">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); font-size: 1em; margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background: rgba(0, 0, 0, 0.1); border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><br /></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; color: var(--syntax-text-color); display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">These parameters are used so that Fastlane can target the developer, the app and the team. It is not obligatory to input any of these, as Fastlane will ask for all of the missing parameters anyway. Sometimes, it is even easier to not input some of these, as for example the team_id and the itc_team_id since Fastlane automatically finds and lists out all of a developer's teams.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">After setting up the Appfile, we will move onto the Fastfile. Open it, remove everything and input the following:<br style="box-sizing: border-box;" /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white;"><span style="font-size: medium;">default_platform(:ios)
platform :ios do
desc "Creates a new app on both App Store Connect and the Apple Developer Portal"
lane :app_create do
produce
end
end</span></span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); font-size: 1em; margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background: rgba(0, 0, 0, 0.1); border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><br /></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">In essence, this lane utilizes the produce command, in order to create a new app on the App Store Connect and Apple Developer sites with a fitting description. The lane is named app_create, but this is arbitrary and can be changed to whatever is most suitable.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Now navigate to the app directory in the terminal and run the command fastlane app_create. Fastlane will prompt the user to input an app name. Make sure it is unique. After the process successfully completes, log in to App Store Connect and the Apple Developer Portal and the new app should now be visible in both places.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="box-sizing: border-box; font-weight: bolder;"><span style="font-family: times; font-size: large;">Generating Certificates and Provisioning Profiles</span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">After the application is created, it is time to generate the required certificates for the app.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The following are some benefits of using Fastlane in order to generate certificates:</span></p><ul style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Saves time! Generating certificates manually is a tedious and dull process.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">If the team decides on it, one account can be used throughout the team which will reduce the number of different provisioning profiles on the Apple Developer Portal keeping it a lot cleaner and easier to manage.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;"><b><br /></b></span></li></ul><p style="background-color: white; box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times; font-size: large;"><b>Follow these steps in order to generate the certificates and provisioning profiles:</b></span></p><ol style="background-color: white; box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; font-size: 20px; margin: 0px;"><span style="font-family: times;">Create one account which will be used by the entire time.</span></li><li style="box-sizing: border-box; font-size: 20px; margin: 0px;"><span style="font-family: times;">Fastlane utilizes Git Repos and Google Cloud Storages to store the certificates for the project in one centralized place. Create either one of these as well as copy the URL.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times; font-size: 20px;">Run <span style="box-sizing: border-box; font-weight: bolder;">match init.</span> </span><span style="font-size: 20px;">This will prompt the user to input the URL from the previous step. </span><span style="font-size: medium;">The result of this command is a new file in the Fastlane folder called Matchfile. It is this file which is used as a reference for generating certificates and provisioning profiles.</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-size: medium;"><br /></span></li></ol><p style="background-color: white; box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times; font-size: medium;">Open the Matchfile, and input this:<br style="box-sizing: border-box;" /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;">git_url ‘[[YOUR PRIVATE GIT REPO URL]]’
app_identifier ‘[[YOUR APP ID]]’
username ‘[[YOUR APPLE DEVELOPER PORTAL USERNAME]]’</span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background: rgba(0, 0, 0, 0.1); border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="font-size: medium;"><br /></span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times; font-size: medium;">Now run the following commands:<br style="box-sizing: border-box;" /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="background-color: white; font-family: times; font-size: medium;">fastlane match app store
</span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;">fastlane match development</span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background: rgba(0, 0, 0, 0.1); border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="font-size: medium;"><br /></span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">This will create the development, App Store certificates and profiles for the application. Easy as pie.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times; font-size: large;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="box-sizing: border-box; font-weight: bolder;"><span style="font-family: times; font-size: large;">Deploy to Testflight with Fastlane</span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">After reaching a certain point in development, we'd like to deploy the app to a selected number of testers who can provide us with feedback. With Fastlane, it is possible to fully automate this release. Let's do this by creating a simple lane for beta release:<br style="box-sizing: border-box;" /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times; font-size: medium;"><span style="background-color: white;">lane :beta do
scan # run tests
match(type: "appstore")
increment_build_number
build_app(scheme: "[[YOUR APP SCHEME]]")
upload_to_testflight
end</span><span style="background-color: rgba(0, 0, 0, 0.1);">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background: rgba(0, 0, 0, 0.1); border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times; font-size: medium;"><br /></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Run the fastlane beta command in order to execute the lane.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The idea behind it is to first run all the tests with the scan command since if they fail, Fastlane automatically stops the execution of the rest of the script.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The upload is now fully automated. However, if we were to log in to the App Store Connect, we would see that before actually submitting the app for beta release we would need to also input the test information for the app. Since Fastlane is used, it would be handy to also automate this input. In order to achieve this, the beta lane could look something like this:<br style="box-sizing: border-box;" /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;">lane :beta do
scan # run tests
match(type: "appstore")
increment_build_number
build_app(scheme: "[[YOUR APP SCHEME]]")
upload_to_testflight(
localized_app_info: {
"default": {
feedback_email: "default@email.com",
marketing_url: "https://example.com/marketing-defafult",
privacy_policy_url: "https://example.com/privacy-defafult",
description: "Default description",
}
},
beta_app_review_info: {
contact_email: "email@email.com",
contact_first_name: "firstname",
contact_last_name: "lastname",
contact_phone: "111222333444",
demo_account_name: "demo account name",
demo_account_password: "demo password",
notes: "This is a review note"
})
end</span><span style="background-color: rgba(0, 0, 0, 0.1); color: var(--color-body-color); font-size: 1em;">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;"><br /></span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; color: var(--syntax-text-color); display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Now when we run the fastlane beta command, all of the test information is uploaded to Testflight, in addition to the binary.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Note that the localized_app_info action may not work but remains in this blog for demonstration purposes.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="box-sizing: border-box;"><span style="font-family: times; font-size: large;"><b>Deploy to App Store with Fastlane</b></span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">After the testers have reviewed the application, it is finally time to upload the app to the App Store. Now we’ll examine a number of steps in order to automate this:</span></p><ul style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0; padding-left: var(--su-6);"><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Creating the deliver file</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Automating screenshots</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Building and uploading to the App store</span></li><li style="box-sizing: border-box; margin: 0px;"><span style="font-family: times;">Creating the Deliver File</span></li></ul><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Run fastlane init deliver in the command line. This will create a number of new folders and files in the Fastlane directory. This includes a Deliverfile, a metadata folder, and a screenshots folder. This is how the Fastlane folder currently looks like:<br style="box-sizing: border-box;" /><a class="article-body-image-wrapper" href="https://res.cloudinary.com/practicaldev/image/fetch/s--5AOoiP1k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtz2m0f0za2dqqgszeve.png" style="box-sizing: border-box; cursor: zoom-in;"><img alt="Alt Text" loading="lazy" src="https://res.cloudinary.com/practicaldev/image/fetch/s--5AOoiP1k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtz2m0f0za2dqqgszeve.png" style="border-radius: var(--radius); box-sizing: border-box; display: block; height: auto; margin: var(--content-rhythm) auto; max-height: calc(50vh + 180px); max-width: 100%;" /></a></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="box-sizing: border-box; font-weight: bolder;"><span style="font-family: times;">Illustration 2: Fastlane folder structure after running Fastlane init deliver</span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The purpose of initializing the Deliver file is so that we can input all of the required metadata and screenshots locally, before submitting it to the App Store. This will then greatly help automate the process. Here is how the new metadata folder is structured:<br style="box-sizing: border-box;" /><a class="article-body-image-wrapper" href="https://res.cloudinary.com/practicaldev/image/fetch/s--rieaYkE3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ynvozvgl3tg37klo006.png" style="box-sizing: border-box; cursor: zoom-in;"><img alt="Alt Text" loading="lazy" src="https://res.cloudinary.com/practicaldev/image/fetch/s--rieaYkE3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ynvozvgl3tg37klo006.png" style="border-radius: var(--radius); box-sizing: border-box; display: block; height: auto; margin: var(--content-rhythm) auto; max-height: calc(50vh + 180px); max-width: 100%;" /></a></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="box-sizing: border-box; font-weight: bolder;"><span style="font-family: times;">Illustration 3: new metadata folder</span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Go through the metadata folder and input all of the different parameters. The en-US folder contains the app information for the English-US language. It is possible to input all of the app's language in the same way, just using different language codes. The app's metadata is now ready to be uploaded.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><h4 style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; font-weight: var(--fw-bold); line-height: var(--lh-tight); margin: calc(var(--content-rhythm) / 2) 0; padding: 0px;"><span style="font-family: times;"><a href="https://dev.to/rubicon_dev/automated-deployment-with-fastlane-on-ios-218p#automating-screenshots" name="automating-screenshots" style="box-sizing: border-box;"></a>Automating Screenshots</span></h4><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Fastlane takes advantage of Apple’s UITesting framework in order to automate screenshots. The basic logic behind it is to run UITests and when a certain point in the test is reached, Fastlane’s snapshot function should be used to capture a screenshot. For example, you can take a screenshot after the UITest executes typing in a username text field on a login screen like this:<br style="box-sizing: border-box;" /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;">userNameTextfield.typeText("Username")
snapshot(“01LoginScreen")</span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;"><br /></span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">We will not be covering how to write tests for automating the screenshots but there are many tutorials online and it’s a fairly straightforward process.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">In order to set up automated screenshots we can do the following:<br style="box-sizing: border-box;" />Run fastlane snapshot init in the project directory. This will create two new files in the Fastlane folder; one called Snapfile and the other one called SnapshotHelper.swift.<br style="box-sizing: border-box;" /><a class="article-body-image-wrapper" href="https://res.cloudinary.com/practicaldev/image/fetch/s--oIlmko4K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctls5q5bjauxdbwyatjz.png" style="box-sizing: border-box; cursor: zoom-in;"><img alt="Alt Text" loading="lazy" src="https://res.cloudinary.com/practicaldev/image/fetch/s--oIlmko4K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctls5q5bjauxdbwyatjz.png" style="border-radius: var(--radius); box-sizing: border-box; display: block; height: auto; margin: var(--content-rhythm) auto; max-height: calc(50vh + 180px); max-width: 100%;" /></a></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="box-sizing: border-box; font-weight: bolder;"><span style="font-family: times;">Illustration 4: Snapfile and SnapshotHelper.swift</span></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Go into the Xcode project and navigate to File -> New -> Target. In the pop-up that appears, find the iOS UI Testing Bundle and press next.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">On the new screen, change the name of the UITests or leave everything as it is and press finish.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">A new folder in the XCode project with the UITests is created. Find the previously created SnapshotHelper.swift and drag and drop it into the new UITests Folder. Note: Make sure to copy it correctly by selecting both the "Copy items if needed" and the UITest target button and then deselecting the project target.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Open “Manage Schemes” in the Xcode project and make sure that both the “Show” and “Shared” checkboxes for the created UITest Schemes are checked.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">In the same window click on the newly created UITest Scheme and press “edit” and then in the new window, window press “Build”.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">This will show the UITest Target with a number of checkboxes. Make sure the checkboxes named “Test” and “Run” are checked. Fastlane can now access the UITest target scheme.<br style="box-sizing: border-box;" />Open the Snapfile, and input this:<br style="box-sizing: border-box;" /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;">devices([
"iPhone X",
"iPhone 8"
])
languages(['en-US'])
scheme("[[YOUR UITEST SCHEME]]")
output_directory "./fastlane/screenshots"
clear_previous_screenshots(true)</span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Now everything is ready for you to capture the screenshots. Input these lines of code in your UITest function in order to utilize the SnapshotHelper.swift:<br style="box-sizing: border-box;" /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;">let app = XCUIApplication()
setupSnapshot(app)
app.launch()</span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); font-size: 1em; margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background: rgba(0, 0, 0, 0.1); border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><br /></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">As I mentioned before, we'll not be covering the actual writing of the UITests since every application has different and specific screens. Therefore, it is the reader’s task to now create the UITests to automate the screenshots of the app.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">After writing the tests, run fastlane snapshot in the terminal and if everything is set up correctly, the screenshots will be taken.</span></p><h3 style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 1.25em; font-weight: var(--fw-bold); line-height: var(--lh-tight); margin: calc(var(--content-rhythm) / 2) 0; padding: 0px;"><span style="font-family: times;"><a href="https://dev.to/rubicon_dev/automated-deployment-with-fastlane-on-ios-218p#building-and-uploading-to-the-app-store" name="building-and-uploading-to-the-app-store" style="box-sizing: border-box;"></a>Building and Uploading to the App Store</span></h3><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">With the deliver file created and screenshots automated, the next step is to upload everything to App Store Connect. A couple of lanes will be individually created for each of the tasks required for the release and then combined together in order to make one lane for the entire release process.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The first lane is for testing:<br style="box-sizing: border-box;" /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="background-color: white; font-family: times; font-size: medium;">lane :test do
desc "Run tests"
scan
end
</span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="background-color: white; font-family: times; font-size: medium;">The next lane is for taking screenshots:<br style="box-sizing: border-box;" /></span></p><p style="box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="background-color: white; font-family: times; font-size: medium;"><br /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="background-color: white; font-family: times; font-size: medium;">lane :screenshots do
desc "Take screenshots"
snapshot
end
</span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="background-color: white; font-family: times; font-size: medium;"><br /></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="background-color: white; font-family: times; font-size: medium;">The third lane is for building the application:<br style="box-sizing: border-box;" /></span></p><p style="box-sizing: border-box; color: #08090a; margin: 0 0 var(--content-rhythm) 0;"><span style="background-color: white; font-family: times; font-size: medium;"><br /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white; font-size: medium;">lane :build do
desc "Build application"
increment_build_number({
build_number: latest_testflight_build_number + 1
})
build_ios_app(
scheme: "[[YOUR APP SCHEME]]"
)
end</span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">increment_build_number checks the latest Testflight build number and increments this build number by 1. This is better than incrementing automatically because sometimes the binary is not uploaded to the App Store/Testflight because of an error, but the build number gets incremented. Bear in mind, that there must be at least one build on Testflight in order to run the latest_testflight_build_number command.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The fourth lane is to upload the binary:<br style="box-sizing: border-box;" /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white;"><span style="font-size: medium;">lane :upload do
desc "Upload metadata, screenshots and binary"
deliver(
force: true,
automatic_release: true,
)
end</span></span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">The deliver command is an alias for the upload_to_app_store action and is used to upload the metadata, screenshots and binary to the App Store. The force: true command is for skipping the HTML preview of the metadata and the automatic_release: true command is to ensure automatic release after the application is reviewed on App Store Connect.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Now all of this can be combined into a single lane called release:<br style="box-sizing: border-box;" /></span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><div class="highlight js-code-highlight" style="border-radius: var(--radius); box-sizing: border-box; color: var(--syntax-text-color); margin: 0 0 var(--content-rhythm) 0; overflow-wrap: initial; overflow-x: auto; position: relative;"><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white;"><span style="font-size: medium;">lane :release do
desc "Run tests, take screenshots, upload deliver file, upload app"
ensure_git_status_clean
test
match(type: "appstore")
screenshots
build
upload
end</span></span><span style="background-color: rgba(0, 0, 0, 0.1); font-size: 1em;">
</span></span></code></pre><pre class="highlight plaintext" style="box-sizing: border-box; color: var(--syntax-text-color); margin-bottom: 0px; margin-top: 0px; overflow: auto; padding: var(--su-6);"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: var(--radius); box-sizing: border-box; color: var(--color-body-color); max-width: 100%; padding: 0px;"><span style="font-family: times;"><span style="background-color: white;"><span style="font-size: medium;"><br /></span></span></span></code></pre><div class="highlight__panel js-actions-panel" style="box-sizing: border-box; display: flex; font-size: 16px; position: absolute; right: 0px; top: 0px; visibility: hidden;"><div class="highlight__panel-action js-fullscreen-code-action" style="border-bottom-left-radius: var(--radius); box-sizing: border-box; display: flex; opacity: 0.9; overflow: hidden; padding: var(--su-2);"><svg class="highlight-action crayons-icon highlight-action--fullscreen-on" height="20px" viewbox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg"></svg><span style="font-family: times;"><path d="M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z"></path></span></div></div></div><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">In addition to the created lanes, the match command is added in order to make sure that the certificates are up-to-date and the ensure_git_status_clean is used to make sure that you are working with a clean Git Repo. With this setup, the version number must be manually incremented. Keep in mind that Fastlane has actions for automatically incrementing version numbers. View this link for more information.</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">Navigate to the project directory and run fastlane release and watch the magic happen!</span></p><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;"><br /></span></p><h3 style="background-color: white; box-sizing: border-box; color: #08090a; line-height: var(--lh-tight); margin: calc(var(--content-rhythm) / 2) 0; padding: 0px;"><span style="font-family: times; font-size: large;"><a href="https://dev.to/rubicon_dev/automated-deployment-with-fastlane-on-ios-218p#concluding-thoughts" name="concluding-thoughts" style="box-sizing: border-box;"></a>Concluding Thoughts</span></h3><p style="background-color: white; box-sizing: border-box; color: #08090a; font-size: 20px; margin: 0 0 var(--content-rhythm) 0;"><span style="font-family: times;">As you can see from this blog, Fastlane is a powerful tool used for automated deployment. Once you become comfortable using it, the scripts and automation tasks will become more advanced and suited for your exact needs. If you feel hesitant about giving it a try, just start with small automation tasks and build upon that. After some time, it will definitely become an important tool in your toolbox.</span></p>shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-15752247871992991292021-05-12T05:29:00.000-07:002021-05-12T05:29:30.299-07:00NSPredicate Cheatsheet, Basic, compound, Aggregate, String, comparison operators<p> <span style="background-color: white; color: #fc9f95; font-family: inherit; font-size: 28px;">Format string summary</span></p><div class="general-predicates-with-descriptions" style="background-color: white; box-sizing: border-box; font-family: realm, lato, Helvetica, Arial, sans-serif; font-size: 18px; max-width: 440px;"><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; color: #59569e; float: left; line-height: 20px; margin: 0px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; color: #1c233f; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@"attributeName == %@"</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">object’s attributeName value is equal to value passed in</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; color: #59569e; float: left; line-height: 20px; margin: 0px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; color: #1c233f; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@"%K == %@"</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">pass a string variable to %K, it will be represented as a keypath, then check if it’s value is equal to value passed in</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; color: #59569e; float: left; line-height: 20px; margin: 0px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; color: #1c233f; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@"%name IN $NAME_LIST"</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">templated for predicate, checks if the value of key name is in $NAME_LIST. Uses predicateWithSubstitutionVariables</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; color: #59569e; float: left; line-height: 20px; margin: 0px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; color: #1c233f; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@"'name' IN $NAME_LIST"</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">checks if the constant value ‘name’ is in $NAME_LIST. Uses predicateWithSubstitutionVariables</p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFormat: @"title == %@", @"minecraft"]</code></p><div style="color: #1c233f;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></div><div style="color: #1c233f;"><span style="color: #59569e; font-family: inherit; font-size: 28px;"><br /></span></div><div style="color: #1c233f;"><span style="color: #59569e; font-family: inherit; font-size: 28px;">String comparison operators</span></div><div><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><div class="predicate-operators-and-descriptions" style="background-color: white; box-sizing: border-box; font-family: realm, lato, Helvetica, Arial, sans-serif; font-size: 18px; font-variant-ligatures: normal; font-weight: 400; max-width: 440px;"><p class="predicate-highlight-operator predicate-with-support-indicator predicate-smaller-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; color: #59569e; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">BEGINSWITH</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression begins with the right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">CONTAINS</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression contains the right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">ENDSWITH</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression ends with the right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">LIKE</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression equals the right hand expression: ? and * are allowed as wildcard characters, where ? matches 1 character and * matches 0 or more characters</p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">MATCHES</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression equals the right hand expression using a regex - style comparison</p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFo<span style="color: #1c233f;">rmat: @"name BEGINSWITH 'm'"]</span></code></p></div><div class="predicate-operators-and-descriptions" style="background-color: white; box-sizing: border-box; color: #1c233f; font-family: realm, lato, Helvetica, Arial, sans-serif; font-size: 18px; font-variant-ligatures: normal; font-weight: 400; max-width: 440px;"></div></code></div><div><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><div class="predicate-operators-and-descriptions" style="background-color: white; box-sizing: border-box; font-family: realm, lato, Helvetica, Arial, sans-serif; font-size: 18px; font-variant-ligatures: normal; font-weight: 400; max-width: 440px;"><h4 class="predicate-with-support-indicator" style="box-sizing: border-box; color: #59569e; font-family: inherit; font-size: 28px; font-weight: 400; line-height: 1.1; margin-bottom: 20px; margin-top: 10px; padding-top: 3rem; position: relative;">Basic comparisons</h4><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; color: #59569e; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; color: #1c233f; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">=,==</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression is equal to right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">>=,=></code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression is greater than or equal to right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;"><=,=<</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression is less than or equal to right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">></code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression is greater than right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;"><</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression is less than right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">!=,<></code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression is not equal to right hand expression</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">IN</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression must appear in collection specified by right hand expression. i.e. name IN {‘Milk’, ‘Eggs’, ‘Bread’}</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">BETWEEN</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Left hand expression is between or equal to right hand expression. i.e. 1 Between {0, 33}. If your left hand expression was 0 or 33 it would also make this true</p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFormat: @"expenses BETWEEN {200, 400}"]</code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><h4 class="predicate-with-support-indicator basic-compound" style="box-sizing: border-box; color: #f77c88; font-size: 28px; font-weight: 400; line-height: 1.1; margin-bottom: 20px; margin-top: 10px; padding-top: 3rem; position: relative;">Basic compound predicates</h4><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; color: #59569e; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; color: #1c233f; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">A</code><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">ND,&&</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Logical AND</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">OR,||</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Logical OR</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">NOT,!</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">Logical NOT</p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFormat: @"age == 40 AND price > 67"]</code></p><h4 class="predicate-with-support-indicator aggregate-operators" style="box-sizing: border-box; color: #59569e; font-family: inherit; font-size: 28px; font-weight: 400; line-height: 1.1; margin-bottom: 20px; margin-top: 10px; padding-top: 3rem; position: relative;">Aggregate operators</h4><h4 class="predicate-with-support-indicator keypath" style="box-sizing: border-box; font-size: 28px; font-weight: 400; line-height: 1.1; margin-bottom: 20px; margin-top: 10px; padding-top: 3rem; position: relative;"><div class="predicate-operators-and-descriptions" style="box-sizing: border-box; font-size: 18px; max-width: 440px;"><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; color: #59569e; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; color: #1c233f; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">A</code><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">NY,SOME</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">returns objects where ANY or SOME of the predicate results are true.</p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">ALL</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">returns objects where ALL of the predicate results are true.</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">NONE</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">returns objects where NONE of the predicate results are true.</p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFormat: @"ALL expenses > 1000"]</code></p></div><div class="general-predicates-with-descriptions" style="box-sizing: border-box; color: #1c233f; font-size: 18px; max-width: 440px;"></div></h4><h4 class="predicate-with-support-indicator keypath" style="box-sizing: border-box; color: #9a50a5; font-size: 28px; font-weight: 400; line-height: 1.1; margin-bottom: 20px; margin-top: 10px; padding-top: 3rem; position: relative;">Keypath collection queries</h4><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; color: #59569e; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@avg</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">returns the average of the objects in the collection as an NSNumber</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@count</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">returns the number of objects in a collection as an NSNumber</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@min</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">returns the minimum value of the objects in the collection as an NSNumber</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@max</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">returns the maximum value of the objects in the collection as an NSNumber</p><p class="predicate-highlight-operator predicate-with-support-indicator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px; position: relative;"><span class="dot-support-indicator pull-left" style="background: rgb(242, 81, 146); border-radius: 50%; box-sizing: border-box; display: inline-block; float: left; height: 6px; left: -16px; margin: -2px 3px 3px 0px; position: absolute; top: 10px; width: 6px;"></span><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@sum</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">returns the sum of the objects in the collection based on the property</p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFormat: @"expenses.@avg.doubleValue < 200"]</code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><span style="color: #59569e; font-size: 28px;">Object, array, and set operators</span></p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@distinctUnionOfObjects</code></p><p class="predicate-description meta predicate-description-below" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">returns an array containing the distinct objects in the property specified by the key path to the right of the operator</p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@unionOfObjects</code></p><p class="predicate-description meta predicate-description-below" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">returns the same as <code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 13.6px; font-variant-ligatures: none; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0.2em 0.3em; position: relative; text-shadow: none; white-space: initial;">@distinctUnionOfObects</code> except it also includes duplicates</p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">NSArray *payees = [transactions valueForKeyPath:@"@distinctUnionOfObjects.payee"]</code></p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@distinctUnionOfArrays</code></p><p class="predicate-description meta predicate-description-below" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">returns an array containing the distinct objects in the property specified by the key path to the right of the operator</p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@unionOfArrays</code></p><p class="predicate-description meta predicate-description-below" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">returns the same as <code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 13.6px; font-variant-ligatures: none; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0.2em 0.3em; position: relative; text-shadow: none; white-space: initial;">@distinctUnionOfArrays</code> except it also includes duplicates</p><p class="predicate-description predicate-description-margin-reset" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">These must be run on an array of arrays. For example if you had:</p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">NSArray *arrayOfTransactions = [[Array of transactions], [Array of transactions]]</code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">NSArray *payees = [arrayOfTransactions valueForKeyPath:@"@distinctUnionOfObjects.payee"]</code></p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">@distinctUnionOfSets</code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"></code></p><p class="predicate-description meta predicate-description-below" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">returns an <code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 13.6px; font-variant-ligatures: none; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0.2em 0.3em; position: relative; text-shadow: none; white-space: initial;">NSSet</code> instance containing distinct objects in the property specified by the key path to the right of the operator. Expects an <code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 13.6px; font-variant-ligatures: none; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0.2em 0.3em; position: relative; text-shadow: none; white-space: initial;">NSSet</code> instance containing <code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 13.6px; font-variant-ligatures: none; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0.2em 0.3em; position: relative; text-shadow: none; white-space: initial;">NSSet</code> instances</p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><span style="color: #59569e; font-size: 28px;">Array operations</span></p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">array[index]</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">specifies the element at the specified index in the array.</p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">array[FIRST]</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">specifies the first element in the array.</p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">array[LAST]</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">specifies the last element in the array.</p><p class="predicate-highlight-operator" style="box-sizing: border-box; clear: both; float: left; line-height: 20px; margin: 0px 0px -30px; min-width: 70px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0px; position: relative; text-shadow: none; white-space: initial;">array[SIZE]</code></p><p class="predicate-description meta" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 20px; margin: 0px 0px 20px 100px;">specifies the size of the array.</p><p class="predicate-description predicate-description-margin-reset" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 10px;">Let’s say we have a person with many dogs. <code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 13.6px; font-variant-ligatures: none; line-height: 1.25em; margin: 0px 0.1em; overflow: auto; padding: 0.2em 0.3em; position: relative; text-shadow: none; white-space: initial;">index</code> should be replaced with a number which will return the dog that you want to check against. Here we’re checking if the first dog’s age is 5.</p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFormat: @"dogs[0].age = 5"]</code></p><p class="predicate-description predicate-description-margin-reset" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 10px;">Here we’re checking if a person has 3 dogs</p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFormat: @"dogs[SIZE] = 3"]</code></p><div class=" predicate-container" style="box-sizing: border-box;"><div class="col-md-6" style="box-sizing: border-box; float: left; min-height: 1px; padding-left: 15px; padding-right: 15px; position: relative; width: 460px;"><div class="general-predicates-with-descriptions" style="box-sizing: border-box; max-width: 440px;"><h4 class="predicate-with-support-indicator subqueries" style="box-sizing: border-box; color: #59569e; font-family: inherit; font-size: 28px; font-weight: 400; line-height: 1.1; margin-bottom: 20px; margin-top: 10px; padding-top: 3rem; position: relative;">Subqueries</h4><p class="meta" style="box-sizing: border-box; line-height: 1.6; margin: 0px 0px 20px;">SUBQUERY(collection, variableName, predicateFormat)</p><p class="predicate-description" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">Iterates through the collection to return qualifying queries</p><p class="predicate-description" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">Collection - array or set of objects</p><p class="predicate-description" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">variableName - variable that represents an iterated object</p><p class="predicate-description" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">predicateFormat - predicate that runs using the variableName</p><p class="predicate-example" style="box-sizing: border-box; clear: both; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;">[NSPredicate predicateWithFormat: @"SUBQUERY(tasks, $task, $task.completionDate != nil AND $task.user = 'Alex') .@count > 0"]</code></p><p class="predicate-description" style="box-sizing: border-box; clear: both; font-size: 16px; line-height: 22px; margin: 0px 0px 20px;">Assume this was run on an array of projects. It will return projects with tasks that were not completed by user Alex</p></div></div></div><hr style="background: rgb(235, 235, 242); border: 0px; box-sizing: content-box; color: #1c233f; height: 2px; margin-bottom: 20px; margin-top: 20px;" /><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"></code></p><div class="col-xs-12 predicate-tips-title-container" style="box-sizing: border-box; color: #1c233f; float: left; min-height: 1px; padding: 30px; position: relative; width: 920px;"></div><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><p class="predicate-example" style="box-sizing: border-box; clear: both; color: #1c233f; line-height: 20px; margin: 0px 0px 10px;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></p><div style="color: #1c233f;"><code class="highlighter-rouge" style="background: 0px 0px rgba(0, 0, 0, 0.04); border-radius: 3px; border: none; box-sizing: border-box; font-family: menlo, "nimbus mono l", monospace, helvetica, sans-serif !important; font-size: 14px; font-variant-ligatures: none; font-weight: 800; line-height: 1.25em; margin: 0px 0.1em; overflow-wrap: break-word; overflow: auto; padding: 0px; position: relative; text-shadow: none;"><br /></code></div></div><div class="predicate-operators-and-descriptions" style="background-color: white; box-sizing: border-box; color: #1c233f; font-family: realm, lato, Helvetica, Arial, sans-serif; font-size: 18px; font-variant-ligatures: normal; font-weight: 400; max-width: 440px;"></div></code></div></div><div class="predicate-operators-and-descriptions" style="background-color: white; box-sizing: border-box; color: #1c233f; font-family: realm, lato, Helvetica, Arial, sans-serif; font-size: 18px; max-width: 440px;"></div>shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-3178166728766890912021-05-12T04:48:00.000-07:002021-05-12T04:48:20.178-07:00CRUD Operation Using RealmSwift database Part 1<p> <span style="background-color: white; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">In this part, we will Cover:</span></p><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd bx" data-selectable-paragraph="" id="16d4" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">What is Realm</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="7495" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">RealmSwift</span></li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="70ed" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Creating a Complex Realm Model</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="59d0" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Why we use @objc and dynamic in Property</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="a226" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">To-One and To-Many Relationship in Realm</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="bb2e" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">How to store Custom enum in Realm</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="908f" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">What is <span class="if jj" style="box-sizing: inherit; font-weight: 700;">RealmOptional and How to Store Swift Optional Atomic Property</span></li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="0446" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">How Computed Property works as Transient Property In realm</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="1943" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">How to do indexing for performance gain</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="3305" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">What is Linking Object in Realm</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="4a8c" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Complex Predicate Queries</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="cd3d" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">CRUD Operation</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="b0cb" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">What is Live Results in Realm</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="cfdf" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Things avoided when Modify Realm Objects</li></ol><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="c77c" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Realm</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="8282" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">Realm is a cross-platform mobile object database. It’s very fast, performant and easy to use as compared to Core Data and Sqlite. It uses its storage mechanism to store object as JSON on disk as compared to Core Data that uses Sqlite as its backend. It is written in cross-platform C++ so it works exactly the same way on Android, iOS, macOS or any other platform.</p><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="2fa7" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">RealmSwift</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="2c03" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;"><a class="cd kl" href="https://academy.realm.io/posts/jp-simard-realm-core-database-engine/" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Most of Realm is open-source, but the secret sauce behind Realm’s platform is the Core DB engine written from scratch in C++.</a> RealmSwift is a wrapper around the Objective-C Realm framework and Objective-C Realm framework is a wrapper around Realm Core DB engine.</p><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="2d32" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Getting Started</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="4cae" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">In this tutorial we will be working on these models as shown in Figure 1</p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="eb19" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">User →</span> It’s a model contains user information in which <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">userId</code> it’s primary. It also has a <span class="if jj" style="box-sizing: inherit; font-weight: 700;">To-one</span> relationship with passport model and <span class="if jj" style="box-sizing: inherit; font-weight: 700;">To-Many </span>relationships with Todo tasks. (User can have only passport and have many todo Tasks)</p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="a214" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">Passport → </span>It’s a model contains passport information of a user and also has a <span class="if jj" style="box-sizing: inherit; font-weight: 700;">reverse back link </span>of <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">User</code> object.</p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="191f" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">Todo → </span>It’s a model contains tasks of a user and also has a <span class="if jj" style="box-sizing: inherit; font-weight: 700;">reverse back link </span>of <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">User</code> object.</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu kr" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 835px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="lb lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 366.453px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 366.453px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="450" role="presentation" src="https://miro.medium.com/max/60/1*O1n3iJKFSWy-0OQHTNKMDQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 366.453px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="835" /></div><img alt="" class="qf wj t u v kx aj c" height="450" role="presentation" sizes="700px" src="https://miro.medium.com/max/1670/1*O1n3iJKFSWy-0OQHTNKMDQ.png" srcset="https://miro.medium.com/max/552/1*O1n3iJKFSWy-0OQHTNKMDQ.png 276w, https://miro.medium.com/max/1104/1*O1n3iJKFSWy-0OQHTNKMDQ.png 552w, https://miro.medium.com/max/1280/1*O1n3iJKFSWy-0OQHTNKMDQ.png 640w, https://miro.medium.com/max/1400/1*O1n3iJKFSWy-0OQHTNKMDQ.png 700w" style="background-color: white; box-sizing: inherit; height: 366.453px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="835" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 1</span></figcaption></figure><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="b584" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">User Model</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="c7dc" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">As shown in Figure 2 we created User model and adds a few properties:</p><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd bx" data-selectable-paragraph="" id="a480" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">First we inherit <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">User</code> class from <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Object</code> which makes it <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Realm Object</code> . <span class="if jj" style="box-sizing: inherit; font-weight: 700;">Realm objects</span> are basically a standard data model, much like any other standard data model you’ve defined in your apps. The only difference is they’re backed by Realm persistence and abilities. By looking into all <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Object</code> class Realm are able to infer your schema. Every model you want to persist you have to inherit from Object class.</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="d506" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">firstName</code> stores the user first name as <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">String</code>. Since <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">RealmSwift</code> is a wrapper around the Objective-C Realm framework Types like <span class="if jj" style="box-sizing: inherit; font-weight: 700;">String, Date and Data are sub-classes of NSObject in Objective-C</span>, so you can consider them object types in Swift as well. In addition to this <a class="cd kl" href="http://twitter.com/objc" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">@objc</span></a><span class="if jj" style="box-sizing: inherit; font-weight: 700;"> </span>means you want your Swift code (class, method, property, etc.) to be visible from Objective-C whereas <span class="if jj" style="box-sizing: inherit; font-weight: 700;">dynamic</span> means you want to use <span class="if jj" style="box-sizing: inherit; font-weight: 700;">Objective-C dynamic dispatch</span>. To make simple swift object stores in database Realm uses <span class="if jj" style="box-sizing: inherit; font-weight: 700;">Objective-C dynamic dispatch </span>feature to do work under the hood</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="ab10" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">userId</code> stores the User id which acts as a primary key. You can set one of your object’s properties as its primary key. Usually, property that uniquely identifies itself, that is a prime candidate for a primary key. It helps you a quick lookup or edit object in a database. As shown in Figure 2 we make <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">userId </code>primary key by overriding <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">primarykey</code> static function. The default implementation of this method return nil.<span class="if jj" style="box-sizing: inherit; font-weight: 700;"> Note </span><code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">userId </code>acts as a Objective C primitive Int type since it is a wrapper around Objective C Realm</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="54f6" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">passport</code> property stores the user passport information which is another Realm Object. We created <span class="if jj" style="box-sizing: inherit; font-weight: 700;">To-One relationship</span> with the Passport Model. <span class="if jj" style="box-sizing: inherit; font-weight: 700;">To-one relationship</span> / object link , in which one realm object point to another realm object. When you create a relationship with another Realm object, its property must be of an Optional type. In passport variable pointer reference of <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Passport</code> object will store</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="96cc" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">privateUserType</code> is the wrapper property of <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">UserType</code> since UserType is swift enum we can’t store directly on Realm. All of its case values would have an implicitly assigned raw value matching the case’s name. You’ll use this raw value to persist the enum options as <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Int</code> in Realm. But client is accessing computed enum property and under the hood enum raw value/atomic value is storing in database which is not visible to client.</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="0a11" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">String, NSDate, and NSData</span> properties can be declared as <span class="if jj" style="box-sizing: inherit; font-weight: 700;">optional or non-optional </span>using the standard Swift syntax.Optional numeric types are declared using <span class="if jj" style="box-sizing: inherit; font-weight: 700;">RealmOptional. </span>Since RealmSwift is wrapper around Objective C Realm and there is no optional Int in Objective C that’s why Realm created it’s type RealmOptional for this scenarios. All the Objective C primitive type require in Swift with Optional you have to use <span class="if jj" style="box-sizing: inherit; font-weight: 700;">RealmOptional .<em class="ll" style="box-sizing: inherit;"> Note: RealmOptional properties cannot be declared as dynamic and @objc keyword because generic properties cannot be represented in the Objective C runtime, which is used for dynamic dispatch of dynamic properties, and should always be declared with let. Since It’s Realm class it has all features that Realm persist object have</em>. </span>As shown in Figure 2 <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">isEmailSubscriptionEnable</code> we declare as <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">RealmOptional</code> Bool means it can be nil we used with let since its a reference type and we don’t want its address to change in future.</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="f195" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">As shown in Figure 2 User can have many todos which is a collection of Realm Todo Objects . List as Realm class to hold collection of the Realm Object instances. We created <span class="if jj" style="box-sizing: inherit; font-weight: 700;">To-Many relationship </span>with the Todo model. <span class="if jj" style="box-sizing: inherit; font-weight: 700;">To-many relationship </span>, in which one realm object point to collection of realm object. If you use normal Swift array to store Realm collection of Object you will get exception. <span class="if jj" style="box-sizing: inherit; font-weight: 700;">Note: Like RealmOptional List cannot be declared as dynamic and </span><a class="cd kl" href="http://twitter.com/objc" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">@objc</span></a><span class="if jj" style="box-sizing: inherit; font-weight: 700;"> </span>keyword since its a Realm class with all the built in features. List is very similar to Array for built in methods and accessing objects using indexed subscripting. List as you see is typed and all objects should be of the same type</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="dde3" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">isUserHasTodos</code> is a computed swift property and will not store in realm database which return if user has some tasks to do or not.</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="e6ec" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Finally we make <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">userId</code> and <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">firstName</code> as indexed properties. By overriding <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">indexedProperties</code> static method we provide array of properties in String form. We do indexed on properties to improve the access times when filtering or querying the database</li></ol><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu lm" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1762px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="ln lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 634.453px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 634.453px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="1644" role="presentation" src="https://miro.medium.com/max/60/1*alpTP09T2W8LrW9bgUepUQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 634.453px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1762" /></div><img alt="" class="qf wj t u v kx aj c" height="1644" role="presentation" sizes="700px" src="https://miro.medium.com/max/3524/1*alpTP09T2W8LrW9bgUepUQ.png" srcset="https://miro.medium.com/max/552/1*alpTP09T2W8LrW9bgUepUQ.png 276w, https://miro.medium.com/max/1104/1*alpTP09T2W8LrW9bgUepUQ.png 552w, https://miro.medium.com/max/1280/1*alpTP09T2W8LrW9bgUepUQ.png 640w, https://miro.medium.com/max/1400/1*alpTP09T2W8LrW9bgUepUQ.png 700w" style="background-color: white; box-sizing: inherit; height: 634.453px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1762" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 2</span></figcaption></figure><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="7be3" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Passport Model</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="711f" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">As shown in Figure 3 we created Passport model with the few properties</p><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd bx" data-selectable-paragraph="" id="6e71" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;"><code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">passportNumber</code> stores the Passport information and <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">expiryDate</code> stores the expiry date of the passport we want these properties to store that’s why we use <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">@objc</code> with <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">dynamic</code> keyword to tell realm do your under the hood magic</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="1344" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">We created <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">passport</code> property on <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">User</code> model which means <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">User</code> object have their <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">passport</code> object reference what if we want passport object also know which user has this passport / have a reference to the user associated with this passport. We created the backlinks using <span class="if jj" style="box-sizing: inherit; font-weight: 700;">LinkingObjects</span> which means we created <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">ofUser</code> property in Passport that have a reference of all User objects that assign Passport object in its <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">passport</code> property. In Core Data its called it as inverse relationship. Its a dynamic collection telling you who links to the current object.</li></ol><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu lo" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1332px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="lp lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 292px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 292px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="572" role="presentation" src="https://miro.medium.com/max/60/1*ec05eAOhioKbprB7VD9Anw.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 292px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1332" /></div><img alt="" class="qf wj t u v kx aj c" height="572" role="presentation" sizes="700px" src="https://miro.medium.com/max/2664/1*ec05eAOhioKbprB7VD9Anw.png" srcset="https://miro.medium.com/max/552/1*ec05eAOhioKbprB7VD9Anw.png 276w, https://miro.medium.com/max/1104/1*ec05eAOhioKbprB7VD9Anw.png 552w, https://miro.medium.com/max/1280/1*ec05eAOhioKbprB7VD9Anw.png 640w, https://miro.medium.com/max/1400/1*ec05eAOhioKbprB7VD9Anw.png 700w" style="background-color: white; box-sizing: inherit; height: 292px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1332" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 3</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="abcb" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 4 we created <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Todo</code> Realm model with has a backlink to the all the users pointing to particular task .</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu lq" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1246px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="lr lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 307.797px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 307.797px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="564" role="presentation" src="https://miro.medium.com/max/60/1*AkL-dutMIkdOV8HmCF7K1Q.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 307.797px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1246" /></div><img alt="" class="qf wj t u v kx aj c" height="564" role="presentation" sizes="700px" src="https://miro.medium.com/max/2492/1*AkL-dutMIkdOV8HmCF7K1Q.png" srcset="https://miro.medium.com/max/552/1*AkL-dutMIkdOV8HmCF7K1Q.png 276w, https://miro.medium.com/max/1104/1*AkL-dutMIkdOV8HmCF7K1Q.png 552w, https://miro.medium.com/max/1280/1*AkL-dutMIkdOV8HmCF7K1Q.png 640w, https://miro.medium.com/max/1400/1*AkL-dutMIkdOV8HmCF7K1Q.png 700w" style="background-color: white; box-sizing: inherit; height: 307.797px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1246" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 4</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="a1db" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">We done with the model / schema creation and now it's time to do actual CRUD operation</p><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="f5e4" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Add Object to Realm</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="8bf4" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">We first clear some concept then we will be able to easily add object in Realm</p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="73e3" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 5 we start by getting an instance of the default <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Realm</code> by initializing it without any arguments. The only way you can access database through realm instance. A <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Realm</code> instance (also referred to as “a Realm”) represents a Realm database.Realms can either be stored on disk (see <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">init(path:)</code>) or in memory (see <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Configuration</code>) we will see in upcoming parts. <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Realm</code> instances are not <span class="if jj" style="box-sizing: inherit; font-weight: 700;">thread safe </span>and cannot be shared across threads or dispatch queues. You must construct a new instance for each thread in which a Realm will be accessed.</p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="6542" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 5 since it’s a fresh app and no object was stored in the database <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">realm.isEmpty</code> returns true means database is empty as printed on the console</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu ls" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1426px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="lt lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 350px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 350px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="734" role="presentation" src="https://miro.medium.com/max/60/1*h4A8VxvrzhgMlOiwg632gQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 350px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1426" /></div><img alt="" class="qf wj t u v kx aj c" height="734" role="presentation" sizes="700px" src="https://miro.medium.com/max/2852/1*h4A8VxvrzhgMlOiwg632gQ.png" srcset="https://miro.medium.com/max/552/1*h4A8VxvrzhgMlOiwg632gQ.png 276w, https://miro.medium.com/max/1104/1*h4A8VxvrzhgMlOiwg632gQ.png 552w, https://miro.medium.com/max/1280/1*h4A8VxvrzhgMlOiwg632gQ.png 640w, https://miro.medium.com/max/1400/1*h4A8VxvrzhgMlOiwg632gQ.png 700w" style="background-color: white; box-sizing: inherit; height: 350px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1426" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 5</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="73ef" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 6 we performed number of tasks</p><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd bx" data-selectable-paragraph="" id="d055" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">We get the instance of <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Realm</code> database</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="eef1" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Created <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Passport</code> and three tasks as a <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">todos</code></li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="a4bc" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Created <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">User</code> object and assign passport and todos to it. In addition to this initialized Realm optional property which is <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">isEmailSubscriptionEnable</code> and <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Usertype</code> enum with gold membership</li></ol><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="c985" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 6 realm database still empty and inverse <span class="if jj" style="box-sizing: inherit; font-weight: 700;">relationship/ Linking object</span> is not working either because we didn’t added these objects to the realm. Realm objects (User,Passport,Todo)can be instantiated and used as unmanaged objects (i.e. not yet added to a Realm) just like regular Swift objects. To make theses objects managed by Realm you have to add them in Realm</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu lu" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1628px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="lv lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 669.125px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 669.125px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="1602" role="presentation" src="https://miro.medium.com/max/60/1*WCcTN69Jo0kvXAzrxSBLdQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 669.125px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1628" /></div><img alt="" class="qf wj t u v kx aj c" height="1602" role="presentation" sizes="700px" src="https://miro.medium.com/max/3256/1*WCcTN69Jo0kvXAzrxSBLdQ.png" srcset="https://miro.medium.com/max/552/1*WCcTN69Jo0kvXAzrxSBLdQ.png 276w, https://miro.medium.com/max/1104/1*WCcTN69Jo0kvXAzrxSBLdQ.png 552w, https://miro.medium.com/max/1280/1*WCcTN69Jo0kvXAzrxSBLdQ.png 640w, https://miro.medium.com/max/1400/1*WCcTN69Jo0kvXAzrxSBLdQ.png 700w" style="background-color: white; box-sizing: inherit; height: 669.125px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1628" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 6</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="1d02" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 7 we finally insert object into Realm database. We performed cascading insert into the DB.</p><blockquote class="lw lx ly" style="background-color: white; box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="id ie ll if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="56ec" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><a class="cd kl" href="https://realm.io/docs/swift/latest/" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">Note: All changes to an object (addition, modification and deletion) must be done within a write transaction.</span></a><span class="if jj" style="box-sizing: inherit; font-weight: 700;">Realm write operations are synchronous and blocking, not asynchronous. If thread A starts a write operation, then thread B starts a write operation on the same Realm before thread A is finished, thread A must finish and commit its transaction before thread B’s write operation takes place. Write operations always refresh automatically so No race condition is created. Write operation can throw error like running out of disk space</span></p></blockquote><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd bx" data-selectable-paragraph="" id="5812" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">We added User to your Realm, and since it references passport and todos, these objects are also added to the Realm.</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="737e" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">By adding unmanaged object to realm we made these objects Managed now as shown in the console our backlinks works. Now passport can access User object as well. Now our database is no more empty</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="485b" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">We finally insert object into the database since we are inserting object we have to add in the write transaction block and we add into the realm by using add method on Realm instance. Now If another separate object with the same primary key of User with <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">userId = 1 </code>is attempted to be added as a separate object to the Realm, an exception will be triggered</li></ol><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu lz" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1924px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="ma lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 578.203px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 578.203px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="1636" role="presentation" src="https://miro.medium.com/max/60/1*e8iPdUA_5oi3grHArCy6bA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 578.203px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1924" /></div><img alt="" class="qf wj t u v kx aj c" height="1636" role="presentation" sizes="700px" src="https://miro.medium.com/max/3848/1*e8iPdUA_5oi3grHArCy6bA.png" srcset="https://miro.medium.com/max/552/1*e8iPdUA_5oi3grHArCy6bA.png 276w, https://miro.medium.com/max/1104/1*e8iPdUA_5oi3grHArCy6bA.png 552w, https://miro.medium.com/max/1280/1*e8iPdUA_5oi3grHArCy6bA.png 640w, https://miro.medium.com/max/1400/1*e8iPdUA_5oi3grHArCy6bA.png 700w" style="background-color: white; box-sizing: inherit; height: 578.203px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1924" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 7</span></figcaption></figure><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="8b1d" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Check Object Physically Store</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="fda7" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">By running this command on debugger output you get the address of realm file where your data is stored</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mb" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1140px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mc lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 164.625px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 164.625px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="276" role="presentation" src="https://miro.medium.com/max/60/1*9Xqv21SR4CJPESBrow7DsA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 164.625px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1140" /></div><img alt="" class="qf wj t u v kx aj c" height="276" role="presentation" sizes="700px" src="https://miro.medium.com/max/2280/1*9Xqv21SR4CJPESBrow7DsA.png" srcset="https://miro.medium.com/max/552/1*9Xqv21SR4CJPESBrow7DsA.png 276w, https://miro.medium.com/max/1104/1*9Xqv21SR4CJPESBrow7DsA.png 552w, https://miro.medium.com/max/1280/1*9Xqv21SR4CJPESBrow7DsA.png 640w, https://miro.medium.com/max/1400/1*9Xqv21SR4CJPESBrow7DsA.png 700w" style="background-color: white; box-sizing: inherit; height: 164.625px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1140" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 8</span></figcaption></figure><blockquote class="lw lx ly" style="background-color: white; box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="id ie ll if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="9c60" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Open <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">default.realm </code>in Realm Studio<br style="box-sizing: inherit;" /><a class="cd kl" href="https://realm.io/products/realm-studio/" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Realm Studio is our premiere developer tool, built so you can easily manage the Realm Database and Realm Platform. With Realm Studio, you can open and edit local and synced Realms, and administer any Realm Object Server instance. Download it now for Mac, Windows, or Linux.</a></p></blockquote><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu md" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1506px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="me lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 254.656px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 254.656px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="564" role="presentation" src="https://miro.medium.com/max/60/1*ZeL06wtU4tu5iqcR5uAxJg.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 254.656px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1506" /></div><img alt="" class="qf wj t u v kx aj c" height="564" role="presentation" sizes="700px" src="https://miro.medium.com/max/3012/1*ZeL06wtU4tu5iqcR5uAxJg.png" srcset="https://miro.medium.com/max/552/1*ZeL06wtU4tu5iqcR5uAxJg.png 276w, https://miro.medium.com/max/1104/1*ZeL06wtU4tu5iqcR5uAxJg.png 552w, https://miro.medium.com/max/1280/1*ZeL06wtU4tu5iqcR5uAxJg.png 640w, https://miro.medium.com/max/1400/1*ZeL06wtU4tu5iqcR5uAxJg.png 700w" style="background-color: white; box-sizing: inherit; height: 254.656px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1506" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 9</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="7161" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 10 data actually stored. You may wonder <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Article</code> and <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Person</code> class also there because in some of my project class create models Person and Article. When application runs, Realm introspects all of the classes in your app and frameworks and finds those classes that subclass Realm’s Object class. It considers the list of these classes to be your data schema that will be persisted on disk or in-memory.</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mf" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2160px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mg lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 291.516px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 291.516px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="926" role="presentation" src="https://miro.medium.com/max/60/1*mvOglGkaN0vqsP0VPN_HUA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 291.516px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2160" /></div><img alt="" class="qf wj t u v kx aj c" height="926" role="presentation" sizes="700px" src="https://miro.medium.com/max/4320/1*mvOglGkaN0vqsP0VPN_HUA.png" srcset="https://miro.medium.com/max/552/1*mvOglGkaN0vqsP0VPN_HUA.png 276w, https://miro.medium.com/max/1104/1*mvOglGkaN0vqsP0VPN_HUA.png 552w, https://miro.medium.com/max/1280/1*mvOglGkaN0vqsP0VPN_HUA.png 640w, https://miro.medium.com/max/1400/1*mvOglGkaN0vqsP0VPN_HUA.png 700w" style="background-color: white; box-sizing: inherit; height: 291.516px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2160" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 10</span></figcaption></figure><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="ff6f" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Fetch Object from Realm</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="c98a" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">The process of <span class="if jj" style="box-sizing: inherit; font-weight: 700;">fetching all the User</span> records from Realm has following tasks</p><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd bx" data-selectable-paragraph="" id="c505" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">We get the instance of Realm Database and it can <span class="if jj" style="box-sizing: inherit; font-weight: 700;">throws</span>: An <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">NSError</code> if the Realm could not be initialized. Default realm is created when we call <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">init()</code> without parameter</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="cc39" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Called objects method on Realm database which will return all objects of the given type stored in the Realm and it will return a Results with all the objects as shown in Figure 11</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="ea8b" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Printed object on console to validate data is there and Linking objects working fine</li></ol><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mh" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1532px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mi lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 395.031px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 395.031px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="890" role="presentation" src="https://miro.medium.com/max/60/1*by6BdD2Ka9dqQzl1nJXqSw.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 395.031px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1532" /></div><img alt="" class="qf wj t u v kx aj c" height="890" role="presentation" sizes="700px" src="https://miro.medium.com/max/3064/1*by6BdD2Ka9dqQzl1nJXqSw.png" srcset="https://miro.medium.com/max/552/1*by6BdD2Ka9dqQzl1nJXqSw.png 276w, https://miro.medium.com/max/1104/1*by6BdD2Ka9dqQzl1nJXqSw.png 552w, https://miro.medium.com/max/1280/1*by6BdD2Ka9dqQzl1nJXqSw.png 640w, https://miro.medium.com/max/1400/1*by6BdD2Ka9dqQzl1nJXqSw.png 700w" style="background-color: white; box-sizing: inherit; height: 395.031px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1532" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 11</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="ac48" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">We <span class="if jj" style="box-sizing: inherit; font-weight: 700;">fetched User</span> record from its primary key which is also a indexed property so we get the optional <span class="if jj" style="box-sizing: inherit; font-weight: 700;">User</span> object since object with this primary key might not exists. Primary key can be <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Int</code> or <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">String</code> The recommendation is to use <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">String.</code> It uniquely identify specific objects in a Realm database.Once a primary key value has been set on a specific object, it cannot ever be changed.</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mj" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2080px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mk lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 307.297px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 307.297px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="940" role="presentation" src="https://miro.medium.com/max/60/1*LLHNI0GbFHPhTxuo-Vs1QQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 307.297px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2080" /></div><img alt="" class="qf wj t u v kx aj c" height="940" role="presentation" sizes="700px" src="https://miro.medium.com/max/4160/1*LLHNI0GbFHPhTxuo-Vs1QQ.png" srcset="https://miro.medium.com/max/552/1*LLHNI0GbFHPhTxuo-Vs1QQ.png 276w, https://miro.medium.com/max/1104/1*LLHNI0GbFHPhTxuo-Vs1QQ.png 552w, https://miro.medium.com/max/1280/1*LLHNI0GbFHPhTxuo-Vs1QQ.png 640w, https://miro.medium.com/max/1400/1*LLHNI0GbFHPhTxuo-Vs1QQ.png 700w" style="background-color: white; box-sizing: inherit; height: 307.297px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2080" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 12</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="fe21" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown we filtered using some Predicate Here are the list of operators we used</p><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd bx" data-selectable-paragraph="" id="9c0a" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">[==] filter → </span>matches values equal to</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="f294" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">[==] [c] filter case insensitive → </span>matches values equal to ignore case</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="dbd3" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">IN {1,2,3} filter → </span>matches value from a list of values.</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="86e8" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">[BEGINSWITH] filter → </span>matches if the firstName value starts with a.</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="a803" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="if jj" style="box-sizing: inherit; font-weight: 700;">[CONTAINS] filter → </span>matches if the firstName value conatins with li.</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="2161" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Predicate with Passport object we want to filter User that have passport number == ‘pass1’</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="6e43" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Predicate with Todos object we want to filter User that have any tdodo contains details == ‘Need ot create RxSwift blog’</li></ol><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="3b52" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">For advanced queries It is highly recommended to see <a class="cd kl" href="https://academy.realm.io/posts/nspredicate-cheatsheet/" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">https://academy.realm.io/posts/nspredicate-cheatsheet/</a> this NSPredicate cheatsheet</p><blockquote class="lw lx ly" style="background-color: white; box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="id ie ll if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="9ab9" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><a class="cd kl" href="https://github.com/realm/realm-cocoa/issues/4423" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Note: What you refer to as “transient (computed) properties”, Realm refers to as “ignored properties”. These are properties that are for the most part ignored by Realm, so they won’t be stored in the db file, can be mutated outside write transactions, etc.However, this also means that they don’t benefit from many of the capabilities of non-ignored properties, <span class="if jj" style="box-sizing: inherit; font-weight: 700;">such as queries</span>.</a> (querying for Realm objects can only be done with non-computed, Realm-persisted properties)</p></blockquote><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu ml" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2550px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mm lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 519.453px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 519.453px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="1948" role="presentation" src="https://miro.medium.com/max/60/1*nRFIAwZmufMdM7k1EXiZxA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 519.453px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2550" /></div><img alt="" class="qf wj t u v kx aj c" height="1948" role="presentation" sizes="700px" src="https://miro.medium.com/max/5100/1*nRFIAwZmufMdM7k1EXiZxA.png" srcset="https://miro.medium.com/max/552/1*nRFIAwZmufMdM7k1EXiZxA.png 276w, https://miro.medium.com/max/1104/1*nRFIAwZmufMdM7k1EXiZxA.png 552w, https://miro.medium.com/max/1280/1*nRFIAwZmufMdM7k1EXiZxA.png 640w, https://miro.medium.com/max/1400/1*nRFIAwZmufMdM7k1EXiZxA.png 700w" style="background-color: white; box-sizing: inherit; height: 519.453px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2550" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 13</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="1d13" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 14 we sorted results with the <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">firstName</code> property on User model</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mn" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1164px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mo lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 218.484px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 218.484px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="374" role="presentation" src="https://miro.medium.com/max/60/1*hiCezMSe-YcwO2u1F7MnUA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 218.484px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1164" /></div><img alt="" class="qf wj t u v kx aj c" height="374" role="presentation" sizes="700px" src="https://miro.medium.com/max/2328/1*hiCezMSe-YcwO2u1F7MnUA.png" srcset="https://miro.medium.com/max/552/1*hiCezMSe-YcwO2u1F7MnUA.png 276w, https://miro.medium.com/max/1104/1*hiCezMSe-YcwO2u1F7MnUA.png 552w, https://miro.medium.com/max/1280/1*hiCezMSe-YcwO2u1F7MnUA.png 640w, https://miro.medium.com/max/1400/1*hiCezMSe-YcwO2u1F7MnUA.png 700w" style="background-color: white; box-sizing: inherit; height: 218.484px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1164" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 14</span></figcaption></figure><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="33fc" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;"><span class="bc" style="box-sizing: inherit; font-weight: inherit;">Live results</span></h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="fbca" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">Last topic on fetching from Realm section</p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="1682" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Realm result sets always return the latest up-to-date data. Data in Results is never outdated. This means you never have to reload results from disk or somehow manually refresh in- memory data.</p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="4c2c" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 15 we got the new user and we didn’t fetch using <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">realm.objects </code>method instead newly added object are presented on users variable . If you come from Core data background you need to again fetched object from the stack</p><blockquote class="lw lx ly" style="background-color: white; box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="id ie ll if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="dc66" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><a class="cd kl" href="https://academy.realm.io/posts/live-objects-fine-grained-notifications-realm-update/" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Reading and writing can happen in different spots in the project, on different threads, from different processes, or, when using the Realm Platform, from anywhere in the world. Each class in the app can focus on the business logic and forget about the notion of outdated or cached data, since Realm objects are always up to date.</a></p></blockquote><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mp" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2246px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mq lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 333.641px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 333.641px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="1102" role="presentation" src="https://miro.medium.com/max/60/1*geHmLi-MnNaLF_Tnrbu__g.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 333.641px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2246" /></div><img alt="" class="qf wj t u v kx aj c" height="1102" role="presentation" sizes="700px" src="https://miro.medium.com/max/4492/1*geHmLi-MnNaLF_Tnrbu__g.png" srcset="https://miro.medium.com/max/552/1*geHmLi-MnNaLF_Tnrbu__g.png 276w, https://miro.medium.com/max/1104/1*geHmLi-MnNaLF_Tnrbu__g.png 552w, https://miro.medium.com/max/1280/1*geHmLi-MnNaLF_Tnrbu__g.png 640w, https://miro.medium.com/max/1400/1*geHmLi-MnNaLF_Tnrbu__g.png 700w" style="background-color: white; box-sizing: inherit; height: 333.641px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2246" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 15</span></figcaption></figure><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="ec26" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Modify Object On Realm</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="1e29" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">As shown in figure 16 we are modifying primary key and we get “Primary key can’t be changed after an object is inserted.” exception since we can’t update primary key . From <a class="cd kl" href="https://realm.io/docs/swift/latest/#updating-objects" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Realm Docs</a> <em class="ll" style="box-sizing: inherit;">primary key is added to a Realm, the primary key cannot be changed. </em>Workaround<em class="ll" style="box-sizing: inherit;"> → </em>Remove and reinsert the object or see this <a class="cd kl" href="https://stackoverflow.com/questions/38522285/update-realm-primary-key-value-swift" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">question</a> in stackoverflow</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mr" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1466px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="ms lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 151.203px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 151.203px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="326" role="presentation" src="https://miro.medium.com/max/60/1*T0fdI789WlPto6UyoGbLlg.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 151.203px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1466" /></div><img alt="" class="qf wj t u v kx aj c" height="326" role="presentation" sizes="700px" src="https://miro.medium.com/max/2932/1*T0fdI789WlPto6UyoGbLlg.png" srcset="https://miro.medium.com/max/552/1*T0fdI789WlPto6UyoGbLlg.png 276w, https://miro.medium.com/max/1104/1*T0fdI789WlPto6UyoGbLlg.png 552w, https://miro.medium.com/max/1280/1*T0fdI789WlPto6UyoGbLlg.png 640w, https://miro.medium.com/max/1400/1*T0fdI789WlPto6UyoGbLlg.png 700w" style="background-color: white; box-sizing: inherit; height: 151.203px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1466" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 16</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="6395" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 17 you can’t modify object fetched from realm outside of write transaction block if you try to modify outside of this you will get exception “<span class="if jj" style="box-sizing: inherit; font-weight: 700;">‘Attempting to modify object outside of a write transaction — call beginWriteTransaction on an RLMRealm instance first.”</span></p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mt" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2526px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mu lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 290.734px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 290.734px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="1080" role="presentation" src="https://miro.medium.com/max/60/1*1pomOxBJq5sM_Itx14Fh9Q.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 290.734px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2526" /></div><img alt="" class="qf wj t u v kx aj c" height="1080" role="presentation" sizes="700px" src="https://miro.medium.com/max/5052/1*1pomOxBJq5sM_Itx14Fh9Q.png" srcset="https://miro.medium.com/max/552/1*1pomOxBJq5sM_Itx14Fh9Q.png 276w, https://miro.medium.com/max/1104/1*1pomOxBJq5sM_Itx14Fh9Q.png 552w, https://miro.medium.com/max/1280/1*1pomOxBJq5sM_Itx14Fh9Q.png 640w, https://miro.medium.com/max/1400/1*1pomOxBJq5sM_Itx14Fh9Q.png 700w" style="background-color: white; box-sizing: inherit; height: 290.734px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2526" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 17</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="2806" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 18 as we modify object in <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">write</code> transaction block it will persist that object into the disk as well as shown in Figure 19 <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">default.realm </code>file now has a updated <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">firstName</code> value of User</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mv" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1934px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mw lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 353.703px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 353.703px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="1006" role="presentation" src="https://miro.medium.com/max/60/1*xD1QY_pKLV-NBGSUNylXqQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 353.703px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1934" /></div><img alt="" class="qf wj t u v kx aj c" height="1006" role="presentation" sizes="700px" src="https://miro.medium.com/max/3868/1*xD1QY_pKLV-NBGSUNylXqQ.png" srcset="https://miro.medium.com/max/552/1*xD1QY_pKLV-NBGSUNylXqQ.png 276w, https://miro.medium.com/max/1104/1*xD1QY_pKLV-NBGSUNylXqQ.png 552w, https://miro.medium.com/max/1280/1*xD1QY_pKLV-NBGSUNylXqQ.png 640w, https://miro.medium.com/max/1400/1*xD1QY_pKLV-NBGSUNylXqQ.png 700w" style="background-color: white; box-sizing: inherit; height: 353.703px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1934" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 18</span></figcaption></figure><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mx" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2166px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="my lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 225.406px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 225.406px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="718" role="presentation" src="https://miro.medium.com/max/60/1*hgloWq9CdRIlMNwnlVoqiw.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 225.406px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2166" /></div><img alt="" class="qf wj t u v kx aj c" height="718" role="presentation" sizes="700px" src="https://miro.medium.com/max/4332/1*hgloWq9CdRIlMNwnlVoqiw.png" srcset="https://miro.medium.com/max/552/1*hgloWq9CdRIlMNwnlVoqiw.png 276w, https://miro.medium.com/max/1104/1*hgloWq9CdRIlMNwnlVoqiw.png 552w, https://miro.medium.com/max/1280/1*hgloWq9CdRIlMNwnlVoqiw.png 640w, https://miro.medium.com/max/1400/1*hgloWq9CdRIlMNwnlVoqiw.png 700w" style="background-color: white; box-sizing: inherit; height: 225.406px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2166" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 19</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="125f" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Last example is very interesting we performed following tasks to update user with the newUser</p><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd bx" data-selectable-paragraph="" id="1979" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">We get the User with its primary key <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">userId</code> which is 1</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="6e4d" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Created new <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">User</code> with the same primary key</li><li class="id ie fo if b ig je ii ij ik jf im in io jg iq ir is jh iu iv iw ji iy iz ja jb jc jd bx" data-selectable-paragraph="" id="04f4" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">On a write transaction we call add <span class="if jj" style="box-sizing: inherit; font-weight: 700;">batch update metho</span>d with update = true it will update the User having primary key = 1 . If update = false it will throw an exception since two objects can’t have same primary key as shown in Figure 20 and 21</li></ol><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu mz" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1970px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="na lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 437.672px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 437.672px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="1268" role="presentation" src="https://miro.medium.com/max/60/1*qAjKn_6CSFyonD1uO_zu2A.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 437.672px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1970" /></div><img alt="" class="qf wj t u v kx aj c" height="1268" role="presentation" sizes="700px" src="https://miro.medium.com/max/3940/1*qAjKn_6CSFyonD1uO_zu2A.png" srcset="https://miro.medium.com/max/552/1*qAjKn_6CSFyonD1uO_zu2A.png 276w, https://miro.medium.com/max/1104/1*qAjKn_6CSFyonD1uO_zu2A.png 552w, https://miro.medium.com/max/1280/1*qAjKn_6CSFyonD1uO_zu2A.png 640w, https://miro.medium.com/max/1400/1*qAjKn_6CSFyonD1uO_zu2A.png 700w" style="background-color: white; box-sizing: inherit; height: 437.672px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1970" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 20</span></figcaption></figure><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu nb" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2210px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="nc lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 214.766px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 214.766px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="698" role="presentation" src="https://miro.medium.com/max/60/1*Si4fKMGDgj9SJhZ3Un3xRQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 214.766px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2210" /></div><img alt="" class="qf wj t u v kx aj c" height="698" role="presentation" sizes="700px" src="https://miro.medium.com/max/4420/1*Si4fKMGDgj9SJhZ3Un3xRQ.png" srcset="https://miro.medium.com/max/552/1*Si4fKMGDgj9SJhZ3Un3xRQ.png 276w, https://miro.medium.com/max/1104/1*Si4fKMGDgj9SJhZ3Un3xRQ.png 552w, https://miro.medium.com/max/1280/1*Si4fKMGDgj9SJhZ3Un3xRQ.png 640w, https://miro.medium.com/max/1400/1*Si4fKMGDgj9SJhZ3Un3xRQ.png 700w" style="background-color: white; box-sizing: inherit; height: 214.766px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2210" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 21</span></figcaption></figure><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="c270" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Delete Object From Realm</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="e28f" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">Any objects currently linking to the deleted ones will set their linking property to nil. If those objects are linked from any List properties, they’re removed from the lists in question.</p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="8565" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 22 and 23 we deleted User object having firstName == ‘ali new User’</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu nd" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1710px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="ne lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 118.5px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 118.5px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="298" role="presentation" src="https://miro.medium.com/max/60/1*GGH5vE8bNoku1xs1WvoxHQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 118.5px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1710" /></div><img alt="" class="qf wj t u v kx aj c" height="298" role="presentation" sizes="700px" src="https://miro.medium.com/max/3420/1*GGH5vE8bNoku1xs1WvoxHQ.png" srcset="https://miro.medium.com/max/552/1*GGH5vE8bNoku1xs1WvoxHQ.png 276w, https://miro.medium.com/max/1104/1*GGH5vE8bNoku1xs1WvoxHQ.png 552w, https://miro.medium.com/max/1280/1*GGH5vE8bNoku1xs1WvoxHQ.png 640w, https://miro.medium.com/max/1400/1*GGH5vE8bNoku1xs1WvoxHQ.png 700w" style="background-color: white; box-sizing: inherit; height: 118.5px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1710" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 22</span></figcaption></figure><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu nf" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1738px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="ng lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 271.516px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 271.516px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="694" role="presentation" src="https://miro.medium.com/max/60/1*VBeW1r2bAq6zvgyGqXrE6w.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 271.516px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1738" /></div><img alt="" class="qf wj t u v kx aj c" height="694" role="presentation" sizes="700px" src="https://miro.medium.com/max/3476/1*VBeW1r2bAq6zvgyGqXrE6w.png" srcset="https://miro.medium.com/max/552/1*VBeW1r2bAq6zvgyGqXrE6w.png 276w, https://miro.medium.com/max/1104/1*VBeW1r2bAq6zvgyGqXrE6w.png 552w, https://miro.medium.com/max/1280/1*VBeW1r2bAq6zvgyGqXrE6w.png 640w, https://miro.medium.com/max/1400/1*VBeW1r2bAq6zvgyGqXrE6w.png 700w" style="background-color: white; box-sizing: inherit; height: 271.516px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1738" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 23</span></figcaption></figure><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="da4e" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 24 we empty Realm database using <code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">deleteAll()</code> method in realm object. As shown in Figure<code class="km kn ko kp kq b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;"> realm.isEmpty</code> returns true</p><figure class="hw hx hy hz ia hv et eu paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ks kt bz ku aj kv" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="et eu nh" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1516px;"><div class="la s bz km" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="ni lc s" style="box-sizing: inherit; height: 0px; padding-bottom: 384.844px;"><div class="bv kw t u v kx aj dk ky kz" style="box-sizing: inherit; height: 384.844px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="t u v kx aj ld le tx ze" height="858" role="presentation" src="https://miro.medium.com/max/60/1*GTb3GD5F7BJemnHmn1pdSw.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 384.844px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1516" /></div><img alt="" class="qf wj t u v kx aj c" height="858" role="presentation" sizes="700px" src="https://miro.medium.com/max/3032/1*GTb3GD5F7BJemnHmn1pdSw.png" srcset="https://miro.medium.com/max/552/1*GTb3GD5F7BJemnHmn1pdSw.png 276w, https://miro.medium.com/max/1104/1*GTb3GD5F7BJemnHmn1pdSw.png 552w, https://miro.medium.com/max/1280/1*GTb3GD5F7BJemnHmn1pdSw.png 640w, https://miro.medium.com/max/1400/1*GTb3GD5F7BJemnHmn1pdSw.png 700w" style="background-color: white; box-sizing: inherit; height: 384.844px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1516" /></div></div></div></div><figcaption class="lg lh ev et eu li lj as b at au av" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="as lk" style="box-sizing: inherit; font-weight: 600;">Figure 24</span></figcaption></figure><blockquote class="lw lx ly" style="background-color: white; box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="id ie ll if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="622e" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Sometimes you need to build some kind of hierarchy between Realm objects, just like you’re used to doing with Swift classes. Unfortunately, Realm does not currently support object inheritance out of the box . WorkAround: <a class="cd kl" href="https://forum.realm.io/t/inheritance-with-realm-confusion/153" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">https://forum.realm.io/t/inheritance-with-realm-confusion/153</a></p></blockquote><h1 class="jk jl fo as jm jn jo ii jp jq jr im js jt ju jv jw jx jy jz ka kb kc kd ke kf bx" data-selectable-paragraph="" id="e145" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Useful Links</h1><p class="id ie fo if b ig kg ii ij ik kh im in io ki iq ir is kj iu iv iw kk iy iz ja fg bx" data-selectable-paragraph="" id="ac3c" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;"><a class="cd kl" href="https://www.raywenderlich.com/9220-realm-tutorial-getting-started" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">https://www.raywenderlich.com/9220-realm-tutorial-getting-started</a><br style="box-sizing: inherit;" /><a class="cd kl" href="https://www.appcoda.com/realm-database-swift/" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">https://www.appcoda.com/realm-database-swift/</a></p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="44d2" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><a class="cd kl" href="https://realm.io/docs/swift/latest/#to-many-relationships" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">https://realm.io/docs/swift/latest/#to-many-relationships</a><br style="box-sizing: inherit;" /><a class="cd kl" href="https://realm.io/docs/swift/latest/#optional-properties" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">https://realm.io/docs/swift/latest/#optional-properties</a></p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="aa3b" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><a class="cd kl" href="https://academy.realm.io/posts/nspredicate-cheatsheet/" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">https://academy.realm.io/posts/nspredicate-cheatsheet/</a></p><p class="id ie fo if b ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja fg bx" data-selectable-paragraph="" id="8758" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><a class="cd kl" href="https://academy.realm.io/posts/nspredicate-cheatsheet/" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">https://academy.realm.io/posts/nspredicate-cheatsheet/</a></p>shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-26910090354934102422021-05-12T04:44:00.000-07:002021-05-12T04:44:35.613-07:00iOS Firebase Part 1 (Cloud Firestore)<p> <span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em;">It is a flexible, scalable NoSQL cloud database to store and sync data for client- and server-side development</span></p><div class="n p" style="box-sizing: inherit; display: flex; justify-content: center;"><div class="ap aq ar as at gl av w" style="box-sizing: inherit; margin: 0px 64px; max-width: 680px; min-width: 0px; width: 680px;"><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="109e" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">Getting Started</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="8fa5" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Step 1 : Create Firebase Project</span></p><ol class="" style="box-sizing: inherit; list-style: none none; margin: 0px; padding: 0px;"><li class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq ky kz la eq" data-selectable-paragraph="" id="1cec" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">Open the <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Firebase</span> console.</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="b320" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Click “<span class="iv cj" style="box-sizing: inherit; font-weight: 700;">CREATE</span> NEW <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">PROJECT</span>”. …</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="ccae" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">The “<span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Create</span> a <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">project</span>” window opens. …</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="40a6" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">The start screen of the <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Firebase</span> console opens. …</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="0a93" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">The “Enter app details” screen opens. …</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="ba67" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Continue the configuration by following the on-screen instruction. …</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="7b33" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Check the server key after the <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">project</span> is <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">created</span></li></ol><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv aco" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1216px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="acp lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 305.328px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 305.328px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="546" role="presentation" src="https://miro.medium.com/max/60/1*8x-hI9ntsP8p1J2jKYcNLA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 305.328px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1216" /></div><img alt="" class="pm vp gd fm fj lq w c" height="546" role="presentation" sizes="700px" src="https://miro.medium.com/max/2432/1*8x-hI9ntsP8p1J2jKYcNLA.png" srcset="https://miro.medium.com/max/552/1*8x-hI9ntsP8p1J2jKYcNLA.png 276w, https://miro.medium.com/max/1104/1*8x-hI9ntsP8p1J2jKYcNLA.png 552w, https://miro.medium.com/max/1280/1*8x-hI9ntsP8p1J2jKYcNLA.png 640w, https://miro.medium.com/max/1400/1*8x-hI9ntsP8p1J2jKYcNLA.png 700w" style="background-color: white; box-sizing: inherit; height: 305.328px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1216" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 1</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="b0cc" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Project → </span>Contains one or more apps, All apps in the same project use the same Firebase store and cloud storage from firebase backend.</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="7cc9" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">App → </span>An app is a specific application on a single platform — for exam<span id="rmm" style="box-sizing: inherit;">p</span>le an iOS client or a web client. A project can contain several apps, but an app can only be in one project. The slightly confusing thing is that sometimes one codebase is several apps — for example you might have two different variants of an Android app, one free and one paid — each can be a different Firebase app. Or you might have a development App that is separate from the release App.</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="1ed9" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Step 2: Connect Client app and Install FireStore</span></p><ol class="" style="box-sizing: inherit; list-style: none none; margin: 0px; padding: 0px;"><li class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq ky kz la eq" data-selectable-paragraph="" id="c0b9" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">Create app</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="3692" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Download <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">GoogleService-Info</code></li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="3931" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Drag into root folder</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="039b" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Add this to your <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">pod ‘Firebase/Firestore’, ‘6.6.0’ </code>podfile</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="80e9" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">pod install</code> from terminal (see my <a class="dc ir" href="https://medium.com/@aliakhtar_16369/distribute-framework-using-private-cocoapods-a8beac16617d" rel="noopener" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">cocoapods</a> blogs )</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="58a8" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">FirebaseApp.configure()</code> on <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">didFinishLaunchingWithOptions </code>as shown in Figure 1</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="d234" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Run the application</li></ol><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv acq" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1878px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="acr lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 527.922px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 527.922px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1458" role="presentation" src="https://miro.medium.com/max/60/1*DjjDWK5mq9_YNCHsm4XKfA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 527.922px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1878" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1458" role="presentation" sizes="700px" src="https://miro.medium.com/max/3756/1*DjjDWK5mq9_YNCHsm4XKfA.png" srcset="https://miro.medium.com/max/552/1*DjjDWK5mq9_YNCHsm4XKfA.png 276w, https://miro.medium.com/max/1104/1*DjjDWK5mq9_YNCHsm4XKfA.png 552w, https://miro.medium.com/max/1280/1*DjjDWK5mq9_YNCHsm4XKfA.png 640w, https://miro.medium.com/max/1400/1*DjjDWK5mq9_YNCHsm4XKfA.png 700w" style="background-color: white; box-sizing: inherit; height: 527.922px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1878" /></div></div></div></div></figure><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv acs" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2236px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="act lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 208px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 208px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="684" role="presentation" src="https://miro.medium.com/max/60/1*1Hx5qOxVEsAuj-czSH7iYw.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 208px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2236" /></div><img alt="" class="pm vp gd fm fj lq w c" height="684" role="presentation" sizes="700px" src="https://miro.medium.com/max/4472/1*1Hx5qOxVEsAuj-czSH7iYw.png" srcset="https://miro.medium.com/max/552/1*1Hx5qOxVEsAuj-czSH7iYw.png 276w, https://miro.medium.com/max/1104/1*1Hx5qOxVEsAuj-czSH7iYw.png 552w, https://miro.medium.com/max/1280/1*1Hx5qOxVEsAuj-czSH7iYw.png 640w, https://miro.medium.com/max/1400/1*1Hx5qOxVEsAuj-czSH7iYw.png 700w" style="background-color: white; box-sizing: inherit; height: 208px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2236" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><a class="dc ir" href="https://www.youtube.com/watch?v=iMkifTEaefE" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 1</span></a></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="f3a6" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Step 3: Create a Cloud Firestore database</span></p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="f622" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Navigate to the <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Database</span> section of the <a class="dc ir" href="https://console.firebase.google.com/project/_/database" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Firebase console</a>. You’ll be prompted to select an existing Firebase project. Follow the database creation workflow.</p><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="0d8e" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">Summary of Cloud FireStore</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="fffc" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">Cloud FireStore is a document database that means it stores your data in a big tree like structure like normal database but everything is placed into documents and collections.</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="5aa1" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Now you can think of document </span>something like a dictionary. It’s got key value pairs, which the firebase folks refers to as fields and the value of these fields can be any of things like string , number , binary values , nested json called maps.</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="d444" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Collections</span> are something collections of documents, there are few rules to these things</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="f0ae" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Rule # 1 →</span> Collections only contains document, no collection of strings</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="e0f6" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Rule # 2 → </span>Documents can’t contain other documents but they can point to other subcollections</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="6310" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Rule # 3 → </span>The root of your database can only consists of collections</p><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="0101" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">Add Data</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="b591" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">As shown in Figure 2 we created a <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">users</code> collection and created a document inside this collection each will represent different user. red — refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. This code will save data to firebase store but what happened we get the authorization error “Missing or insufficient permissions.”</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="432f" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Cloud Firestore contains a set of security rules that determine whether or not a certain action is permitted or not. By default they are setup that nobody can read or write to the database</p><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv acu" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2288px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="acv lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 466.594px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 466.594px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1570" role="presentation" src="https://miro.medium.com/max/60/1*Z97LGTzyL2RBD4INjgbuJA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 466.594px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2288" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1570" role="presentation" sizes="700px" src="https://miro.medium.com/max/4576/1*Z97LGTzyL2RBD4INjgbuJA.png" srcset="https://miro.medium.com/max/552/1*Z97LGTzyL2RBD4INjgbuJA.png 276w, https://miro.medium.com/max/1104/1*Z97LGTzyL2RBD4INjgbuJA.png 552w, https://miro.medium.com/max/1280/1*Z97LGTzyL2RBD4INjgbuJA.png 640w, https://miro.medium.com/max/1400/1*Z97LGTzyL2RBD4INjgbuJA.png 700w" style="background-color: white; box-sizing: inherit; height: 466.594px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2288" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 2</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="40de" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Solution 1 (Proper Solution)</span> → To add sign In using Firebase auth and then create some proper well thought security rules based on what information I am willing to share with each user</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="d446" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Solution 2 (Not recommended) </span>→ Make sample data open to public Go to Firebase console → Go in Database → Rules → Change <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">allow read, write: if</code> <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">false;</span> to <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">true; → Publish </span>as shown in Figure 3</p><blockquote class="lg lh li" style="box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="29be" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;"><span class="gn" style="box-sizing: inherit; font-style: normal;">Note: This completely turns off security for the database! </span></span><span class="gn" style="box-sizing: inherit; font-style: normal;">Making it world writable without authentication!!! This is NOT a solution to recommend for a production environment. Only use this for testing purposes.</span></p></blockquote><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv acw" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1936px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="acx lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 312.594px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 312.594px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="890" role="presentation" src="https://miro.medium.com/max/60/1*ld3dt7wU0ILQjaX6hEHp3g.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 312.594px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1936" /></div><img alt="" class="pm vp gd fm fj lq w c" height="890" role="presentation" sizes="700px" src="https://miro.medium.com/max/3872/1*ld3dt7wU0ILQjaX6hEHp3g.png" srcset="https://miro.medium.com/max/552/1*ld3dt7wU0ILQjaX6hEHp3g.png 276w, https://miro.medium.com/max/1104/1*ld3dt7wU0ILQjaX6hEHp3g.png 552w, https://miro.medium.com/max/1280/1*ld3dt7wU0ILQjaX6hEHp3g.png 640w, https://miro.medium.com/max/1400/1*ld3dt7wU0ILQjaX6hEHp3g.png 700w" style="background-color: white; box-sizing: inherit; height: 312.594px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1936" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 3</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="4b7c" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 4.1 and 4.2 we are successfully stored data into Firestore</p><blockquote class="lg lh li" style="box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="cae1" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Note: addDocument always add a new document to this collection with the specified data, assigning it a document ID automatically.</p></blockquote><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv acy" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2274px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="acz lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 331.922px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 331.922px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1110" role="presentation" src="https://miro.medium.com/max/60/1*xsU00twDpPG0MH6M-3Dyvg.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 331.922px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2274" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1110" role="presentation" sizes="700px" src="https://miro.medium.com/max/4548/1*xsU00twDpPG0MH6M-3Dyvg.png" srcset="https://miro.medium.com/max/552/1*xsU00twDpPG0MH6M-3Dyvg.png 276w, https://miro.medium.com/max/1104/1*xsU00twDpPG0MH6M-3Dyvg.png 552w, https://miro.medium.com/max/1280/1*xsU00twDpPG0MH6M-3Dyvg.png 640w, https://miro.medium.com/max/1400/1*xsU00twDpPG0MH6M-3Dyvg.png 700w" style="background-color: white; box-sizing: inherit; height: 331.922px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2274" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><a class="dc ir" href="https://firebase.google.com/docs/firestore/quickstart#secure_your_data" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 4.1</span></a></figcaption></figure><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv aea" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2614px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="aeb lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 213.828px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 213.828px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="822" role="presentation" src="https://miro.medium.com/max/60/1*8vZzNMsP1suNn8ahf9LuoA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 213.828px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2614" /></div><img alt="" class="pm vp gd fm fj lq w c" height="822" role="presentation" sizes="700px" src="https://miro.medium.com/max/5228/1*8vZzNMsP1suNn8ahf9LuoA.png" srcset="https://miro.medium.com/max/552/1*8vZzNMsP1suNn8ahf9LuoA.png 276w, https://miro.medium.com/max/1104/1*8vZzNMsP1suNn8ahf9LuoA.png 552w, https://miro.medium.com/max/1280/1*8vZzNMsP1suNn8ahf9LuoA.png 640w, https://miro.medium.com/max/1400/1*8vZzNMsP1suNn8ahf9LuoA.png 700w" style="background-color: white; box-sizing: inherit; height: 213.828px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2614" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 4.2</span></figcaption></figure><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="7055" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">Update Data</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="56be" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">As shown in Figure 5 we update data by its document id.</p><blockquote class="lg lh li" style="box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="70a2" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Note: To create or overwrite a single document, use the <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">set()</code> method . If the document does not exist, it will be created. If the document does exist, its contents will be overwritten with the newly provided data</p></blockquote></div></div><div class="ig" style="box-sizing: inherit; clear: both;"><div class="n p" style="box-sizing: inherit; display: flex; justify-content: center;"><div class="mn mo mp mq mr ms as mt at mu av w" style="box-sizing: inherit; margin: 0px 64px; max-width: 1192px; min-width: 0px; width: 1192px;"><div class="lk ll lm ln lo n ax" style="box-sizing: inherit; display: flex; flex-direction: row; margin-top: 56px;"><figure class="aec ig aed el mw mv aee paragraph-image" style="box-sizing: inherit; clear: both; margin: 0px 10px 0px 0px; padding-bottom: 5px; padding-top: 5px; width: 532.734px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 532.734px; z-index: auto;" tabindex="0"><img alt="" class="il im" height="560" role="presentation" src="https://miro.medium.com/max/3312/1*Qo_LvtxkhfEFQz7ujFCiuQ.png" style="box-sizing: inherit; height: auto; max-width: 100%; vertical-align: middle;" width="1656" /></div></figure><figure class="aec ig aef el mw mv aee paragraph-image" style="box-sizing: inherit; clear: both; margin: 0px; padding-bottom: 5px; padding-top: 5px; width: 649.266px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 649.266px; z-index: auto;" tabindex="0"><img alt="" class="il im" height="626" role="presentation" src="https://miro.medium.com/max/4512/1*ykyW-uOt8dBGsYSLJWPb1g.png" style="box-sizing: inherit; height: auto; max-width: 100%; vertical-align: middle;" width="2256" /></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd aeg ao aeh aei" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; left: calc(9% - 8px); line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; position: relative; text-align: center; transform: translateX(-50%); width: 728px;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 5</span></figcaption></figure></div></div></div></div><div class="n p" style="box-sizing: inherit; display: flex; justify-content: center;"><div class="ap aq ar as at gl av w" style="box-sizing: inherit; margin: 0px 64px; max-width: 680px; min-width: 0px; width: 680px;"><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="c1e5" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 6 since no user exists in database by using set on document created that user as a document with document id = 123 what we specified and add it to the users collections</p></div></div><div class="ig" style="box-sizing: inherit; clear: both;"><div class="n p" style="box-sizing: inherit; display: flex; justify-content: center;"><div class="mn mo mp mq mr ms as mt at mu av w" style="box-sizing: inherit; margin: 0px 64px; max-width: 1192px; min-width: 0px; width: 1192px;"><div class="lk ll lm ln lo n ax" style="box-sizing: inherit; display: flex; flex-direction: row; margin-top: 56px;"><figure class="aec ig aej el mw mv aee paragraph-image" style="box-sizing: inherit; clear: both; margin: 0px 10px 0px 0px; padding-bottom: 5px; padding-top: 5px; width: 659.094px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 659.094px; z-index: auto;" tabindex="0"><img alt="" class="il im" height="444" role="presentation" src="https://miro.medium.com/max/3648/1*6PhgdYVBjHMgcH1D2NGCIw.png" style="box-sizing: inherit; height: auto; max-width: 100%; vertical-align: middle;" width="1824" /></div></figure><figure class="aec ig aek el mw mv aee paragraph-image" style="box-sizing: inherit; clear: both; margin: 0px; padding-bottom: 5px; padding-top: 5px; width: 522.906px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 522.906px; z-index: auto;" tabindex="0"><img alt="" class="il im" height="578" role="presentation" src="https://miro.medium.com/max/3768/1*4Bnt2tIE_5z4ln4XCE_E2Q.png" style="box-sizing: inherit; height: auto; max-width: 100%; vertical-align: middle;" width="1884" /></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd ael ao aem aei" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; left: calc(-13% - 8px); line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; position: relative; text-align: center; transform: translateX(-50%); width: 728px;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 6</span></figcaption></figure></div></div></div></div><div class="n p" style="box-sizing: inherit; display: flex; justify-content: center;"><div class="ap aq ar as at gl av w" style="box-sizing: inherit; margin: 0px 64px; max-width: 680px; min-width: 0px; width: 680px;"><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="9848" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Now if you want to update only the <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">born date</code> of the user with <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">id = 123</code> you were thinking to write code like this as shown in Figure 7</p><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv ie" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1960px;"><img alt="" class="il im" height="488" role="presentation" src="https://miro.medium.com/max/3920/1*u42bO69TcBdXpURIuSfFyQ.png" style="box-sizing: inherit; height: auto; max-width: 100%; vertical-align: middle;" width="1960" /></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 7</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="304d" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">😠 we overwrites the document referred to by this `FIRDocumentReference`. The question is how update only specific field. I will show in next command but before that put that as we have before</p><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv aen" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1814px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="aeo lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 144.688px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 144.688px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="386" role="presentation" src="https://miro.medium.com/max/60/1*PqxY7rwQpGJfaGoQFRXEzA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 144.688px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1814" /></div><img alt="" class="pm vp gd fm fj lq w c" height="386" role="presentation" sizes="700px" src="https://miro.medium.com/max/3628/1*PqxY7rwQpGJfaGoQFRXEzA.png" srcset="https://miro.medium.com/max/552/1*PqxY7rwQpGJfaGoQFRXEzA.png 276w, https://miro.medium.com/max/1104/1*PqxY7rwQpGJfaGoQFRXEzA.png 552w, https://miro.medium.com/max/1280/1*PqxY7rwQpGJfaGoQFRXEzA.png 640w, https://miro.medium.com/max/1400/1*PqxY7rwQpGJfaGoQFRXEzA.png 700w" style="background-color: white; box-sizing: inherit; height: 144.688px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1814" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 8</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="d7c2" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 9.1 and 9.2 we update only the fields we specify not the whole document</p><blockquote class="lg lh li" style="background-color: white; box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="bea7" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Note: merge → If the document does not exist, it will be created. If the document does exist, its contents will be merged into the existing document, as follows:</p></blockquote><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv aep" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1660px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="aeq lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 213.828px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 213.828px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="522" role="presentation" src="https://miro.medium.com/max/60/1*7ym-lJRMX_MIRNdy5dQ9cQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 213.828px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1660" /></div><img alt="" class="pm vp gd fm fj lq w c" height="522" role="presentation" sizes="700px" src="https://miro.medium.com/max/3320/1*7ym-lJRMX_MIRNdy5dQ9cQ.png" srcset="https://miro.medium.com/max/552/1*7ym-lJRMX_MIRNdy5dQ9cQ.png 276w, https://miro.medium.com/max/1104/1*7ym-lJRMX_MIRNdy5dQ9cQ.png 552w, https://miro.medium.com/max/1280/1*7ym-lJRMX_MIRNdy5dQ9cQ.png 640w, https://miro.medium.com/max/1400/1*7ym-lJRMX_MIRNdy5dQ9cQ.png 700w" style="background-color: white; box-sizing: inherit; height: 213.828px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1660" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 9.1</span></figcaption></figure><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv aer" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1998px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="aes lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 153.141px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 153.141px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="450" role="presentation" src="https://miro.medium.com/max/60/1*18jVnn2wYY_99RcApE-lfQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 153.141px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="1998" /></div><img alt="" class="pm vp gd fm fj lq w c" height="450" role="presentation" sizes="700px" src="https://miro.medium.com/max/3996/1*18jVnn2wYY_99RcApE-lfQ.png" srcset="https://miro.medium.com/max/552/1*18jVnn2wYY_99RcApE-lfQ.png 276w, https://miro.medium.com/max/1104/1*18jVnn2wYY_99RcApE-lfQ.png 552w, https://miro.medium.com/max/1280/1*18jVnn2wYY_99RcApE-lfQ.png 640w, https://miro.medium.com/max/1400/1*18jVnn2wYY_99RcApE-lfQ.png 700w" style="background-color: white; box-sizing: inherit; height: 153.141px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="1998" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 9.2</span></figcaption></figure><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="9758" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Useful Links</h1><figure class="lk ll lm ln lo ig" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px 0px 0px;"><div class="lu s ao" style="box-sizing: inherit; margin: auto; position: relative;"><div class="aet lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 382.188px;"><iframe allowfullscreen="" class="gd fm fj lq w" frameborder="0" height="480" scrolling="auto" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FiMkifTEaefE%3Ffeature%3Doembed&display_name=YouTube&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DiMkifTEaefE&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FiMkifTEaefE%2Fhqdefault.jpg&key=a19fcc184b9711e1b4764040d3dc5c07&type=text%2Fhtml&schema=youtube" style="box-sizing: inherit; height: 382.188px; left: 0px; position: absolute; top: 0px; width: 680px;" title="[NEWER VERSION AVAILABLE] Getting Started with Firebase on iOS - Firecasts" width="854"></iframe></div></div></figure><div class="mz na nb nc nd ne" style="background-color: white; box-shadow: rgb(230, 230, 230) 0px 0px 0px 1px inset; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin-top: 32px;"><a href="https://firebase.google.com/docs/firestore/quickstart#secure_your_data" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit; text-decoration-line: none;" target="_blank"><div class="es n ab" style="box-sizing: inherit; display: flex; flex: 0 0 auto; padding: 0px;"><div class="nf n ak p ng nh" style="box-sizing: inherit; display: flex; flex-direction: column; flex: 1 1 auto; justify-content: center; padding: 16px 20px;"></div></div></a></div></div></div>shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-33253956715713695252021-05-12T04:37:00.001-07:002021-05-12T04:37:45.909-07:00SwiftUI Series <p><span style="font-family: arial;"><b> Declarative Programming :- </b></span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">In </span><a class="dc ir" href="https://en.wikipedia.org/wiki/Computer_science" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">computer science</a><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">,</span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;"> </span><span class="iv cj" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-weight: 700; letter-spacing: -0.003em;">declarative programming</span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;"> </span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">is a</span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;"> </span><a class="dc ir" href="https://en.wikipedia.org/wiki/Programming_paradigm" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">programming paradigm</a><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;"> </span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">— a style of building the structure and elements of computer programs — that expresses the logic of a</span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;"> </span><a class="dc ir" href="https://en.wikipedia.org/wiki/Computation" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">computation</a><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;"> </span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">without describing its</span><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;"> </span><a class="dc ir" href="https://en.wikipedia.org/wiki/Control_flow" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">control flow</a><span style="color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em;">. D</span><span class="iv cj" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-weight: 700; letter-spacing: -0.003em;">eclarative programming is an alternative of imperative programming</span></p><div class="n p" style="box-sizing: inherit; display: flex; justify-content: center;"><div class="ap aq ar as at gl av w" style="box-sizing: inherit; margin: 0px 64px; max-width: 680px; min-width: 0px; width: 680px;"><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="e43e" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">For example, let’s say we have a property name <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">text</code> in the controller which is driving the label.</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="1e57" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">In <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;"><span class="iv cj" style="box-sizing: inherit; font-family: inherit; font-weight: 700;">i<span id="rmm" style="box-sizing: inherit;"><span id="rmm" style="box-sizing: inherit;"><span id="rmm" style="box-sizing: inherit;"><span id="rmm" style="box-sizing: inherit;"><span id="rmm" style="box-sizing: inherit;"><span id="rmm" style="box-sizing: inherit;"><span id="rmm" style="box-sizing: inherit;">m</span></span></span></span></span></span></span>perative</span></code> world every time text property update we need to call the <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">updateLabel</code> method. Here we are manually controlling our program flow</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="9469" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">In <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">declarative/reactive </span>world we can somehow bind<span class="iv cj" style="box-sizing: inherit; font-weight: 700;"> </span><code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">updateLabel</code> method to this <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">text</code> property and whenever this property change our <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">updateLabel</code> method will react and executed</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="977b" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Traditionally, you’ve near always seen this in observer pattern where it provides a common method for providing a “trigger” to allow information to be updated whenever such a change is made (or, in more common OO terms, when an “event” is fired.) In that sense, it provides a simple <em class="kx" style="box-sizing: inherit;">mechanism</em> for allowing the basic concept of reactive programming to happen in OO (and sometimes other) style languages.</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="467a" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">In the RxSwift <a class="dc ir" href="https://medium.com/flawless-app-stories/rxswift-part-1-2e8e2b9586db" rel="noopener" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">blog</a> series I wrote this definition . If you want to learn Rx I made five parts that cover almost every Rx concept</p><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="5fb2" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">SwiftUI Introduction</h1><ol class="" style="box-sizing: inherit; list-style: none none; margin: 0px; padding: 0px;"><li class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq ky kz la eq" data-selectable-paragraph="" id="2f32" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 0.86em; padding-left: 0px;">Introduced in 2019 WWDC</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="ceac" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Available from iOS 13 onwards</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="aaa5" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Need Xcode 11 or above</li></ol><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="9b88" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">SwiftUI Definitions</h1><blockquote class="lg lh li" style="box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="5a3f" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">State driven declarative UI framework.</p></blockquote><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="3513" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">Explanation:</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="0934" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">Here they means <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">State driven</span> ( as I explained in above Declarative Programming section) means UI is bind with some data and when data update UI update automatically.</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="f374" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">In definition there is another term declarative UI. Here in SwiftUI they mean Traditionally we have created UI ‘s using imperative UI. Strict and explicit user interfaces describing sizes, adding subviews and relationship between views . <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Declarative</span> UI however is where you describe your UI in terms of its hierarchy and reusable components and then you trust framework to translate what you have written and it will do all the hard work to render a visual result with huge performance as compared to UIKit. In short</p><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="e197" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">OR</h1><blockquote class="lg lh li" style="box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="2d03" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">It is a framework for creating user interfaces that dramatically reduces the amount of boilerplate code we need to create UI’s (Meaning you can focus on what makes your app unique)</p></blockquote><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="fbcd" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">OR</h1><blockquote class="lg lh li" style="box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="f490" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">SwiftUI is a new framework that is designed to give you the shortest path to building a great app.(<a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=50" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">means giving you the </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=51" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">shortest path to building great </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=54" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">user interfaces.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=55" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">But even though SwiftUI is a new </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=57" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">framework, a lot of it will </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=59" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">already look familiar to you.</a> <a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=61" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">And that’s because it has all of </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=64" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">the basic components that you’d </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=65" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">expect from a UI framework.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=67" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">It has controls like buttons and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=70" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">text fields.</a> <a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=71" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">It has layout containers like </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=73" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">stacks and lists.</a> <a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=75" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">It has drawing, animations and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=78" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">gestures. </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=79" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">And SwiftUI even embraces </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=81" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">platform-specific concepts like </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=83" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">menus on the Mac, the Digital </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=85" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Crown on Apple Watch, and the </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=87" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Siri remote on Apple TV. </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=89" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">And so the takeaway here is that </a>they <a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=93" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">’re not trying to reinvent the </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=94" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">wheel with SwiftUI.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=96" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">But as we all know, the reality </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=99" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">is that just knowing how to use </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=100" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">these kinds of components is not </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=102" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">what it takes to build a great </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=105" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">app, because a great app also </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=108" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">needs to account for these kinds </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=110" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">of things.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=111" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">It needs to be accessible and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=113" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">work with features like dynamic </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=115" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">type.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=116" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">It needs to adapt to different </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=117" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">devices and screen sizes and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=120" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">input types.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=121" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">And it needs to come alive with </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=123" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">things like interactive </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=124" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">animations and support for </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=126" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">system features like Dark Mode </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=128" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">and Drag and Drop.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=130" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">These are the kinds of things </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=132" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">that help your app to reach the </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=134" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">largest possible audience and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=136" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">also help keep it feeling </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=138" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">modern.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=139" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Now we all know that even this </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=143" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">though is not the whole picture, </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=146" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">because of course you also add </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=147" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">in your own unique features that </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=149" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">make your apps stand out from </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=151" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">the crowd.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=152" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">So I just want to take a moment </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=154" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">to step back and acknowledge </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=156" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">that this is a lot of stuff to </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=158" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">have to learn.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=159" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">It’s a lot of stuff to have to </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=160" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">code and maintain, and so how </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=163" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">can SwiftUI help you with all </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=167" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">this? </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=168" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Well, think about your own apps </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=169" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">for a moment.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=170" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">First, you have those basic </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=171" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">features that everyone expects </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=173" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">from your app, like controls and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=175" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">navigation, being accessible and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=177" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">adapting your layout to </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=178" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">different devices.</a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=180" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">We need to do these things and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=182" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">we need to do them right in </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=184" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">order to build a really great </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=186" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">app.</a>So <a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=202" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">the goal of SwiftUI is </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=204" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">pretty simple: we want you to </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=207" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">spend as much of your time as </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=208" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">possible on that fun stuff and </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=210" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">less time on the basic stuff, </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=212" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">but without compromising on </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=215" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">quality.</a> <a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=216" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">And this is what we mean by </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=218" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">giving you the shortest path to </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=220" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">a great app. </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=222" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">Because all of you are building </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=223" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">great apps already.</a>)</p></blockquote><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="199a" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">Benefits</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="24ab" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">When we further dig into this framework with example then majority of the benefits we will understand</p><ol class="" style="box-sizing: inherit; list-style: none none; margin: 0px; padding: 0px;"><li class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq ky kz la eq" data-selectable-paragraph="" id="7bd0" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Remove all UI inconsistencies</span></li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="f41e" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Ended debate between create UI from code or from Interface builder</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="d565" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Declarative UI update</span></li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="a984" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Some aspect of Reactive Programming</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="37ef" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">There is only one tunnel / path where you ca update your UI</span></li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="3dbd" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;"><span class="iv cj" style="box-sizing: inherit; font-weight: 700;">Easy to create compositional UI</span></li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="ef08" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Easy to create atomic reusable component</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="9e80" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Easy to refactor</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="4335" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Adaptive UI</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="e983" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Less and easy code</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="82a3" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Automatically do localisation, and accessibility features</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="0d24" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Towards the Value type Protocol Oriented Programming</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="aebb" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">You Never face over and under constraints error</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="82d7" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Compatible with UIKit</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="2543" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Live rendering</li></ol><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="dc91" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">In this whole series , this blog part I will refer majority of the time . Since most of the people understand benefit with the example</p><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="ba23" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">Getting Started</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="2aab" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">To get started, please create a new iOS project in Xcode called “SwiftUISeries”, choosing the Single View App template and choosing <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">SwiftUI for the User Interface</span>.</p><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="e038" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Xcode 11 includes intuitive new design tools that make building interfaces with SwiftUI as easy as dragging and dropping. As you work in the design canvas, everything you edit is completely in sync with the code in the adjoining editor.</p><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv lj" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 3328px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="lv lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 371.453px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 371.453px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1818" role="presentation" src="https://miro.medium.com/max/60/1*O2v8eBOUUg_tFkfen5dwZQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 371.453px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="3328" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1818" role="presentation" sizes="700px" src="https://miro.medium.com/max/6656/1*O2v8eBOUUg_tFkfen5dwZQ.png" srcset="https://miro.medium.com/max/552/1*O2v8eBOUUg_tFkfen5dwZQ.png 276w, https://miro.medium.com/max/1104/1*O2v8eBOUUg_tFkfen5dwZQ.png 552w, https://miro.medium.com/max/1280/1*O2v8eBOUUg_tFkfen5dwZQ.png 640w, https://miro.medium.com/max/1400/1*O2v8eBOUUg_tFkfen5dwZQ.png 700w" style="background-color: white; box-sizing: inherit; height: 371.453px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="3328" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 1</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="2e10" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">In SwiftUI code in Code Editor is instantly visible as a preview as you type, and any change you make to that preview immediately appears in your code. Xcode recompiles your changes instantly and inserts them into a running version of your app, visible, and editable at all times. As shown in Gif 1 as we add Button in canvas it automatically added in code and you can do vice versa as well. In swiftUI View definition is always swift code and and visual also generate swift code , so the person who like UI through code and through editor can live together</p><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="fu fv lz" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 600px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="ma lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 375px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 375px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 600px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="375" role="presentation" src="https://miro.medium.com/freeze/max/60/1*SAO6J8hH3gOIQiW7aOJjEg.gif?q=20" style="box-sizing: inherit; filter: blur(20px); height: 375px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 600px;" width="600" /></div><img alt="" class="pm vp gd fm fj lq w c" height="375" role="presentation" sizes="600px" src="https://miro.medium.com/max/1200/1*SAO6J8hH3gOIQiW7aOJjEg.gif" srcset="https://miro.medium.com/max/552/1*SAO6J8hH3gOIQiW7aOJjEg.gif 276w, https://miro.medium.com/max/1104/1*SAO6J8hH3gOIQiW7aOJjEg.gif 552w, https://miro.medium.com/max/1200/1*SAO6J8hH3gOIQiW7aOJjEg.gif 600w" style="background-color: white; box-sizing: inherit; height: 375px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 600px;" width="600" /></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Gif 1</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="e2b6" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 2 if you are coming from UIKit framework , we created a label and put it at the center of the screen. Let’s understand it and break things into bullets</p><ol class="" style="box-sizing: inherit; list-style: none none; margin: 0px; padding: 0px;"><li class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq ky kz la eq" data-selectable-paragraph="" id="17d7" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">SwiftUI you work on the value types , a struct conforming to the View protocol and it only has a single requirement , a body property which provides some sort of UI element to be rendered. <a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=1262" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">If you’re coming from UIKit or </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=1264" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">AppKitt, you’ve probably gotten </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=1266" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">used to views being defined as </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=1267" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">classes that inherit from a </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=1269" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">common view superclass instead </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=1272" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">of as structs conforming to </a><a class="dc ir" href="https://developer.apple.com/videos/play/wwdc2019-216/?time=1273" rel="noopener nofollow" style="-webkit-tap-highlight-color: transparent; box-sizing: inherit;">protocols.</a></li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="f943" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">There is a ‘some’ keyword as a return type which allow the type of view to be automatically inferred without explicitly setting its return type in code . They enable us to use generic protocols as functions’ return types while keeping the concrete type information private.</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="8350" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Body property is an associated type so as long as there is a single element this is fine. Since the view protocol uses an associated type under the hood without specifying some keyword your are actually rendering a protocol with only a generic constraint not a concerete type. This some keyword return an opaque type which allows it to act as if it really were a concerete type.</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="4e64" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">In Swift UI View is basic building block of user interface (define a piece of UI)</li></ol><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv mb" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2092px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mc lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 435.562px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 435.562px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1340" role="presentation" src="https://miro.medium.com/max/60/1*s3QzawKEP6KMWNGdVoxGbw.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 435.562px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2092" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1340" role="presentation" sizes="700px" src="https://miro.medium.com/max/4184/1*s3QzawKEP6KMWNGdVoxGbw.png" srcset="https://miro.medium.com/max/552/1*s3QzawKEP6KMWNGdVoxGbw.png 276w, https://miro.medium.com/max/1104/1*s3QzawKEP6KMWNGdVoxGbw.png 552w, https://miro.medium.com/max/1280/1*s3QzawKEP6KMWNGdVoxGbw.png 640w, https://miro.medium.com/max/1400/1*s3QzawKEP6KMWNGdVoxGbw.png 700w" style="background-color: white; box-sizing: inherit; height: 435.562px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2092" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 2</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="42bb" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 3 you get some error , when tries to add two label (Text) on the screen. This is because when creating a SwiftUI view, you describe its content, layout, and behavior in the view’s body property, however the body property only returns a single view. You can combine and embed multiple views in Stacks, which group views together horizontally, vertically, or back to front.</p><blockquote class="lg lh li" style="box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="655d" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">Stacks acts like container and in SwiftUI provides three distinct stacks, <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">HStack</span> → which arranges its children(i.e. subviews) in a horizontal line, next to each other. <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">VStack →</span> which arranges its children in a vertical line, i.e above and below each other. <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">ZStack → </span>which overlays its children, i.e. places them on top of each other, back to front, along the z depth axis. In later part we will cover this in details</p></blockquote><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv md" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2868px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="me lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 355.172px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 355.172px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1498" role="presentation" src="https://miro.medium.com/max/60/1*PslVOEbs3pxkHpvIkVwMcw.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 355.172px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2868" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1498" role="presentation" sizes="700px" src="https://miro.medium.com/max/5736/1*PslVOEbs3pxkHpvIkVwMcw.png" srcset="https://miro.medium.com/max/552/1*PslVOEbs3pxkHpvIkVwMcw.png 276w, https://miro.medium.com/max/1104/1*PslVOEbs3pxkHpvIkVwMcw.png 552w, https://miro.medium.com/max/1280/1*PslVOEbs3pxkHpvIkVwMcw.png 640w, https://miro.medium.com/max/1400/1*PslVOEbs3pxkHpvIkVwMcw.png 700w" style="background-color: white; box-sizing: inherit; height: 355.172px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2868" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 3</span></figcaption></figure><p class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="6cc8" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">As shown in Figure 4 we put in container and now we respect SwiftUI and return only one view which is a VStack.</p><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv mf" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2762px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mg lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 257.016px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 257.016px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1044" role="presentation" src="https://miro.medium.com/max/60/1*R0aiz0t9wxgHy5OdmLWVGA.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 257.016px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2762" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1044" role="presentation" sizes="700px" src="https://miro.medium.com/max/5524/1*R0aiz0t9wxgHy5OdmLWVGA.png" srcset="https://miro.medium.com/max/552/1*R0aiz0t9wxgHy5OdmLWVGA.png 276w, https://miro.medium.com/max/1104/1*R0aiz0t9wxgHy5OdmLWVGA.png 552w, https://miro.medium.com/max/1280/1*R0aiz0t9wxgHy5OdmLWVGA.png 640w, https://miro.medium.com/max/1400/1*R0aiz0t9wxgHy5OdmLWVGA.png 700w" style="background-color: white; box-sizing: inherit; height: 257.016px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2762" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 4</span></figcaption></figure><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="eff7" style="box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; letter-spacing: 0px; line-height: 36px; margin: 1.95em 0px -0.28em;">Modifiers</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="9de7" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">As shown in Figure 5 we added some styling to our <code class="ks kt ku kv kw b" style="background-color: #f2f2f2; box-sizing: inherit; font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-size: 15.75px; padding: 2px 4px;">Text</code> component for that we called some builtin method. We call these kinds of methods <span class="iv cj" style="box-sizing: inherit; font-weight: 700;">modifiers</span> and they’re used in SwiftUI to customize the way your views look or behave.<span class="iv cj" style="box-sizing: inherit; font-weight: 700;"> . </span>Few things to note</p><ol class="" style="box-sizing: inherit; list-style: none none; margin: 0px; padding: 0px;"><li class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq ky kz la eq" data-selectable-paragraph="" id="aff3" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">Modifier creates a<span class="iv cj" style="box-sizing: inherit; font-weight: 700;"> new view</span> from an existing view. 😲 When the text is modified, a new view is inserted that wraps our existing text The new view tells SwiftUI to render that text with its new font. as shown in Figure 5.1 These modifiers can even be chained together.</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="6f35" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">As shown in Figure 5 we change the text color of our title by adding a foreground color modifier. This adds another view into the view Tree that wraps our font modifier view as shown in Figure 5.2</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="fc51" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">Now clearly our view hierarchy is starting to get bigger pretty quickly. And for the experienced UI programmers, this may be setting off some internal alarm bells. Because over the years we’ve trained ourselves to optimize the performance of our apps by keeping our view hierarchies as small and light as possible. But remember, we’re writing declarative code. And SwiftUI is our expert chef taking our views and skillfully producing a rendered result according to just what we ordered. And so even though we had to wrap our text in multiple wrapper views, SwiftUI collapses that down behind the scenes into an efficient data structure that is then used by the render system.And without having to worry about the performance impact, you’ll find that this chaining modifier syntax actually provides a lot of really nice benefits. In short don’t worry about that</li></ol><blockquote class="lg lh li" style="box-shadow: rgb(41, 41, 41) 3px 0px 0px 0px inset; box-sizing: inherit; margin: 0px 0px 0px -20px; padding-left: 23px;"><p class="it iu kx iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq cw eq" data-selectable-paragraph="" id="5e13" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; font-style: italic; letter-spacing: -0.003em; line-height: 32px; margin: 2em 0px -0.46em; word-break: break-word;">SwiftUI encourages you to create small reusable views, then customize them with modifiers for the specific context where you use them. And don’t worry, SwiftUI collapses the modified view into an efficient data structure, so you get all this convenience with no visible performance hit.</p></blockquote><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv mh" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2784px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mi lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 265.25px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 265.25px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1086" role="presentation" src="https://miro.medium.com/max/60/1*Tvb4-NR2ZBSnrM_dhMdvYQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 265.25px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2784" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1086" role="presentation" sizes="700px" src="https://miro.medium.com/max/5568/1*Tvb4-NR2ZBSnrM_dhMdvYQ.png" srcset="https://miro.medium.com/max/552/1*Tvb4-NR2ZBSnrM_dhMdvYQ.png 276w, https://miro.medium.com/max/1104/1*Tvb4-NR2ZBSnrM_dhMdvYQ.png 552w, https://miro.medium.com/max/1280/1*Tvb4-NR2ZBSnrM_dhMdvYQ.png 640w, https://miro.medium.com/max/1400/1*Tvb4-NR2ZBSnrM_dhMdvYQ.png 700w" style="background-color: white; box-sizing: inherit; height: 265.25px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2784" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 5</span></figcaption></figure><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="fu fv mj" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 174px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mk lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 128px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 128px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 174px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="128" role="presentation" src="https://miro.medium.com/max/60/1*agh-fVL_o3CjD56ROP-mlw.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 128px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 174px;" width="174" /></div><img class="pm vp gd fm fj lq w c" height="149" role="presentation" sizes="174px" src="https://miro.medium.com/max/348/1*agh-fVL_o3CjD56ROP-mlw.png" srcset="" style="background-color: white; box-sizing: inherit; height: 128px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 174px;" width="203" /></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 5.1</span></figcaption></figure><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px auto 0px;"><div class="fu fv ml" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 238px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="mm lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 164px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 164px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 238px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="164" role="presentation" src="https://miro.medium.com/max/60/1*RRmGgsrr3Tq_V08qz6fCiQ.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 164px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 238px;" width="238" /></div><img alt="" class="pm vp gd fm fj lq w c" height="164" role="presentation" sizes="238px" src="https://miro.medium.com/max/476/1*RRmGgsrr3Tq_V08qz6fCiQ.png" srcset="" style="background-color: white; box-sizing: inherit; height: 164px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 238px;" width="238" /></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 5.2</span></figcaption></figure></div></div><div class="ig" style="box-sizing: inherit; clear: both;"><div class="n p" style="box-sizing: inherit; display: flex; justify-content: center;"><div class="mn mo mp mq mr ms as mt at mu av w" style="box-sizing: inherit; margin: 0px 64px; max-width: 1192px; min-width: 0px; width: 1192px;"><figure class="lk ll lm ln lo ig mv mw paragraph-image" style="box-sizing: inherit; clear: both; margin: 56px 0px 0px; padding-bottom: 5px; padding-top: 5px;"><div class="fu fv au" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 1192px;"><img alt="" class="il im" height="164" role="presentation" src="https://miro.medium.com/max/476/1*RRmGgsrr3Tq_V08qz6fCiQ.png" style="box-sizing: inherit; height: auto; max-width: 100%; vertical-align: middle;" width="238" /></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 5.1</span></figcaption></figure></div></div></div><div class="n p" style="box-sizing: inherit; display: flex; justify-content: center;"><div class="ap aq ar as at gl av w" style="box-sizing: inherit; margin: 0px 64px; max-width: 680px; min-width: 0px; width: 680px;"><h1 class="jr js gn ba jt ju jv iy jw jx jy jc jz ka kb kc kd ke kf kg kh ki kj kk kl km eq" data-selectable-paragraph="" id="93a1" style="background-color: white; box-sizing: inherit; color: #292929; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 30px; font-weight: 500; line-height: 36px; margin: 1.95em 0px -0.28em;">Modifier Order Is Important</h1><p class="it iu gn iv b iw kn iy iz ja ko jc jd je kp jg jh ji kq jk jl jm kr jo jp jq cw eq" data-selectable-paragraph="" id="21ed" style="background-color: white; box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; margin: 0.86em 0px -0.46em; word-break: break-word;">As shown in Figure 6 , you can see very straight forward that order is important.</p><ol class="" style="background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; list-style: none none; margin: 0px; padding: 0px;"><li class="it iu gn iv b iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq ky kz la eq" data-selectable-paragraph="" id="1073" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 2em; padding-left: 0px;">Let’s consider Text1, it first create a Text view with default font, then font will create another View and update to headline type. Then foregroundColor will create another view and change all its child color to yellow , then background color will create another View and change all its child color to blue then finally padding will create another view and will add padding. (That’s why background color is not apply to padding)</li><li class="it iu gn iv b iw lb iy iz ja lc jc jd je ld jg jh ji le jk jl jm lf jo jp jq ky kz la eq" data-selectable-paragraph="" id="35e8" style="box-sizing: inherit; color: #292929; font-family: charter, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px; letter-spacing: -0.003em; line-height: 32px; list-style-type: decimal; margin-bottom: -0.46em; margin-left: 30px; margin-top: 1.05em; padding-left: 0px;">In Text 2 we add padding first then background color that’s why it is working as expected</li></ol><figure class="lk ll lm ln lo ig fu fv paragraph-image" style="background-color: white; box-sizing: inherit; clear: both; color: rgba(0, 0, 0, 0.8); font-family: medium-content-sans-serif-font, -apple-system, system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; margin: 56px auto 0px;"><div class="ih ii ao ij w ik" role="button" style="box-sizing: inherit; cursor: zoom-in; position: relative; transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) 0s; width: 680px; z-index: auto;" tabindex="0"><div class="fu fv mx" style="box-sizing: inherit; margin-left: auto; margin-right: auto; max-width: 2838px;"><div class="lu s ao ks" style="background-color: #f2f2f2; box-sizing: inherit; margin: auto; position: relative;"><div class="my lw s" style="box-sizing: inherit; height: 0px; padding-bottom: 311px;"><div class="eo lp gd fm fj lq w lr ls lt" style="box-sizing: inherit; height: 311px; left: 0px; opacity: 0; overflow: hidden; position: absolute; top: 0px; transform: translateZ(0px); transition: opacity 100ms ease 400ms; width: 680px; will-change: transform;"><img alt="" class="gd fm fj lq w lx ly fn yg" height="1298" role="presentation" src="https://miro.medium.com/max/60/1*2i0gnF03dqG4HGaMlw-Log.png?q=20" style="box-sizing: inherit; filter: blur(20px); height: 311px; left: 0px; position: absolute; top: 0px; transform: scale(1.1); transition: visibility 0ms ease 400ms; vertical-align: middle; visibility: hidden; width: 680px;" width="2838" /></div><img alt="" class="pm vp gd fm fj lq w c" height="1298" role="presentation" sizes="700px" src="https://miro.medium.com/max/5676/1*2i0gnF03dqG4HGaMlw-Log.png" srcset="https://miro.medium.com/max/552/1*2i0gnF03dqG4HGaMlw-Log.png 276w, https://miro.medium.com/max/1104/1*2i0gnF03dqG4HGaMlw-Log.png 552w, https://miro.medium.com/max/1280/1*2i0gnF03dqG4HGaMlw-Log.png 640w, https://miro.medium.com/max/1400/1*2i0gnF03dqG4HGaMlw-Log.png 700w" style="background-color: white; box-sizing: inherit; height: 311px; left: 0px; opacity: 1; position: absolute; top: 0px; transition: opacity 400ms ease 0ms; vertical-align: middle; width: 680px;" width="2838" /></div></div></div></div><figcaption class="in io fw fu fv ip iq ba b bb bc bd" data-selectable-paragraph="" style="box-sizing: inherit; color: #757575; font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-left: auto; margin-right: auto; margin-top: 10px; max-width: 728px; text-align: center;"><span class="ba is" style="box-sizing: inherit; font-weight: 600;">Figure 6</span></figcaption><div><span class="ba is" style="box-sizing: inherit; font-weight: 600;"><br /></span></div></figure></div></div>shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-57239842466934932892018-02-08T00:55:00.000-08:002018-02-08T00:55:16.188-08:00Multi threading? Concurrency? Asynchronous task? GCD (Grand Central Dispatch) ? in Swift Programming <div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<b><span style="font-size: large;">Introduction of Grand Central Dispatch</span></b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: blue;">Grand central dispatch is the powerful api for multitasking with sync and async programming in iOS.</span></div>
<div style="text-align: left;">
<br /></div>
<b>Grand Central Dispatch (GCD)</b> is a low-level API for managing concurrent operations. It will make your application smooth and more responsive. Also helps for improving application performance. Sometimes we are trying to perform multiple tasks at the same time that time most of the developer-facing application hang or freezing issue this is the common issue. That’s why we are using <b>GCD</b> to manage multiple tasks at the same time.<br />
<div>
<br /></div>
<div>
<br /></div>
<div style="text-align: left;">
<br /></div>
<span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="font-size: 21px; letter-spacing: -0.063px;">DispatchQueue</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">The DispatchQueue API like a company 🏢..</span></span><span style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; letter-spacing: -0.063px;">Who having staff units like junior level and senior level workers 👷🏼. </span><span style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; letter-spacing: -0.063px;">So now the company can take both heavy and light work with </span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; letter-spacing: -0.063px;">there team.</span><br />
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; color: rgba(0, 0, 0, 0.84); letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px;"><br /></span></span></span></div>
<span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="font-size: 21px; letter-spacing: -0.063px;">DispatchQueue.main.async {</span></span><br />
<span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="font-size: 21px; letter-spacing: -0.063px;"> // Perform your async code here</span></span><br />
<span class="markup--strong markup--h3-strong"><span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; font-size: 21px; letter-spacing: -0.063px;"></span></span></span><br />
<span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="font-size: 21px; letter-spacing: -0.063px;">}</span></span><br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="font-size: 21px; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><span style="color: rgba(0, 0, 0, 0.83921568627451);"><span style="background-color: white;">Concurrenct- </span></span></b></span></span></span><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">It’s starting multiple tasks at the same time but not guarantee for the finish at same time. Its can finish any order.</span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; color: rgba(0, 0, 0, 0.84); letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px;"><br /></span></span></span></div>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="font-size: 21px; letter-spacing: -0.063px;"><b>Serial- </b></span></span><span style="color: rgba(0, 0, 0, 0.84); font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; letter-spacing: -0.063px;">It’s executing one task at a time.</span><br />
<span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="font-size: 21px; letter-spacing: -0.063px;"><br /></span></span>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif; font-size: large;"><span style="letter-spacing: -0.063px;"><b>Sync vs Async</b></span></span><br />
<span class="markup--strong markup--h3-strong"><span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; font-size: 21px; letter-spacing: -0.063px;"></span></span></span><br />
<span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="font-size: 21px; letter-spacing: -0.063px;"><br /></span></span>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="color: rgba(0, 0, 0, 0.84); letter-spacing: -0.063px;"><span style="font-size: large;"><b>Sync -</b> </span></span><span style="letter-spacing: -0.063px;">When a work item is executed synchronously with the sync method, the program waits until execution finishes before the method call returns.</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif; font-size: large;"><span style="letter-spacing: -0.063px;"><b>Code Example Sync</b></span></span><br />
<br />
<span style="background-color: white;"><br /></span>
<span style="background-color: white; color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">f</span><span style="letter-spacing: -0.063px;">unc syncWork(){</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> let northZone = DispatchQueue(label: "perform_task_with_team_north")</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> let southZone = DispatchQueue(label: "perform_task_with_team_south")</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> </span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> northZone.sync {</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> for numer in 1...3{ print("North \(numer)")}</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> southZone.sync {</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> for numer in 1...3{ print("South \(numer)") }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> </span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> //Call Func here </span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> syncWork()</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"> </span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;">//Output</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;">// North 1</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;">// North 2</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;">// North 3</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;">// South 1</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;">// South 2</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;">// South 3</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif; font-size: large;"><span style="letter-spacing: -0.063px;"><b><br /></b></span></span>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><b><span style="font-size: large;">Async - </span></b>execute asynchronously with the async method, the method call returns immediately.</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<b style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: x-large; letter-spacing: -0.063px;">Code Example Async</b><br />
<b style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: x-large; letter-spacing: -0.063px;"><br /></b>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">func asyncWork(){</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> let northZone = DispatchQueue(label: "perform_task_with_team_north")</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> let southZone = DispatchQueue(label: "perform_task_with_team_south")</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> </span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> northZone.async {</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> for numer in 1...3{ print("North \(numer)") }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> southZone.async {</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> for numer in 1...3{ print("South \(numer)") }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">//Call Async Task</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">asyncWork()</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">//OutPut </span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">// North 1</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">// South 1</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">// North 2</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">// South 2</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">// North 3</span></span><br />
<br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">// South 3</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; color: rgba(0, 0, 0, 0.84); letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px;"><br /></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; font-size: 21px; letter-spacing: -0.063px;"><span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;">Perform network task with UI updates -</span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Global Queue -</b>Using to perform non-UI work in the background.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Main Queue -</b>Using to update the UI after completing work in a task on a concurrent queue.</div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><br /></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><br /></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b>List of DispatchQueue Priority -</b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif; font-size: large;"><b><br /></b></span></span></span></div>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">.userInteractive</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">.userInitiated</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">.default</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">.utility</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">.background</span></span><br />
<span class="markup--strong markup--h3-strong"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"></span></span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">.unspecified</span></span><br />
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b>Perform background Quality of Service (QOS) task -</b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><br /></b></span></span></span></div>
<div style="text-align: left;">
<br /></div>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">DispatchQueue.global(qos: .background).async { </span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> // Call your background task</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> DispatchQueue.main.async { </span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> // UI Updates here for task complete.</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> }</span></span><br />
<span class="markup--strong markup--h3-strong"><span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"></span></span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">}</span></span><br />
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><br /></b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><br /></b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b>DispatchQueue with delay ⏳</b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><br /></b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><br /></b></span></span></span></div>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">let deadlineTime = DispatchTime.now() + .seconds(1)</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">DispatchQueue.main.asyncAfter(deadline: deadlineTime) {</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> //Perform code here</span></span><br />
<span class="markup--strong markup--h3-strong"><span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"></span></span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">}</span></span><br />
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><br /></b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><br /></b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b>Dispatch Groups 👨👨👦👦</b></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><b><br /></b></span></span></span></div>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">let dispatchGroup = DispatchGroup()</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">dispatchGroup.enter()</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">loadUseractivities { dispatchGroup.leave() }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">dispatchGroup.enter()</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">loaduserComments { dispatchGroup.leave() }</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"><br /></span></span>
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">dispatchGroup.notify(queue: .main) {</span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;"> print("all activities complete ")</span></span><br />
<span class="markup--strong markup--h3-strong"><span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="background-color: white; letter-spacing: -0.063px;"></span></span></span><br />
<span style="color: blue; font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><span style="letter-spacing: -0.063px;">}</span></span><br />
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><br /></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; font-size: 21px; letter-spacing: -0.063px;"><span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><br /></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; font-size: 21px; letter-spacing: -0.063px;"><span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><br /></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; font-size: 21px; letter-spacing: -0.063px;"><span style="color: rgba(0, 0, 0, 0.83921568627451); font-family: medium-content-serif-font, Georgia, Cambria, Times New Roman, Times, serif;"><br /></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; color: rgba(0, 0, 0, 0.84); letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px;"><br /></span></span></span></div>
<div style="text-align: left;">
<span class="markup--strong markup--h3-strong"><span style="background-color: white; color: rgba(0, 0, 0, 0.84); letter-spacing: -0.063px;"><span style="font-family: medium-content-serif-font, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 21px;"><br /></span></span></span></div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-58232236666061935142018-02-07T05:47:00.000-08:002018-02-07T05:47:25.918-08:00How to calculate height of a multiline String in Swift<div dir="ltr" style="text-align: left;" trbidi="on">
Calculate Height of text to set dynamic height for complete Text<br />
<br />
<div class="crayon-line" id="crayon-5a7af22005fda373078428-1" style="background: 0px center rgb(253, 253, 253); border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<b><span class="crayon-r" style="border: 0px; box-sizing: inherit; color: rgb(128 , 0 , 128); font-family: inherit; font-size: inherit; font-style: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">import</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-e" style="border: 0px; box-sizing: inherit; color: rgb(0 , 78 , 208); font-family: inherit; font-size: inherit; font-style: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">UIKit</span></b></div>
<div class="crayon-line crayon-striped-line" id="crayon-5a7af22005fda373078428-2" style="background: rgb(247, 247, 247) !important; border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-r" style="border: 0px; box-sizing: inherit; color: rgb(128 , 0 , 128); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">extension</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-t" style="border: 0px; box-sizing: inherit; color: rgb(128 , 0 , 128); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">String</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">{</span></div>
<div class="crayon-line" id="crayon-5a7af22005fda373078428-3" style="background: 0px center rgb(253, 253, 253); border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-r" style="border: 0px; box-sizing: inherit; color: rgb(128 , 0 , 128); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">func</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-e" style="border: 0px; box-sizing: inherit; color: rgb(0 , 78 , 208); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">heightWithConstrainedWidth</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">width</span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">CGFloat</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">font</span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">UIFont</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-></span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-e" style="border: 0px; box-sizing: inherit; color: rgb(0 , 78 , 208); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">CGFloat</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="crayon-h" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><br />
<span class="crayon-r" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(128 , 0 , 128); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">let</span><span class="crayon-h" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">constraintRect</span><span class="crayon-h" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-o" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="crayon-h" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-e" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 78 , 208); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">CGSize</span><span class="crayon-sy" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="crayon-v" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">width</span><span class="crayon-o" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">width</span><span class="crayon-sy" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="crayon-h" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">height</span><span class="crayon-o" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-sy" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="crayon-v " style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">greatestFiniteMagnitude</span><span class="crayon-sy" style="background-color: #f7f7f7; border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">)</span><br />
<span class="crayon-r" style="border: 0px; box-sizing: inherit; color: rgb(128 , 0 , 128); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">let</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">boundingBox</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-r" style="border: 0px; box-sizing: inherit; color: rgb(128 , 0 , 128); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">self</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="crayon-v " style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">boundingRect</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">with</span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">constraintRect</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span></div>
<div class="crayon-line" id="crayon-5a7af22005fda373078428-5" style="background: 0px center rgb(253, 253, 253); border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">options</span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="crayon-v " style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">usesLineFragmentOrigin</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="crayon-v " style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">usesFontLeading</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><br />
<span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">attributes</span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">NSFontAttributeName</span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">font</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">context</span><span class="crayon-o" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">nil</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">)</span></div>
<div class="crayon-line crayon-striped-line" id="crayon-5a7af22005fda373078428-6" style="background: rgb(247, 247, 247) !important; border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-st" style="border: 0px; box-sizing: inherit; color: rgb(128 , 0 , 128); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">return</span><span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">boundingBox</span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="crayon-v " style="border: 0px; box-sizing: inherit; color: rgb(0 , 45 , 122); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">height</span></div>
<div class="crayon-line" id="crayon-5a7af22005fda373078428-7" style="background: 0px center rgb(253, 253, 253); border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-h" style="border: 0px; box-sizing: inherit; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">}</span></div>
<div class="crayon-line crayon-striped-line" id="crayon-5a7af22005fda373078428-8" style="background: rgb(247, 247, 247) !important; border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-sy" style="border: 0px; box-sizing: inherit; color: rgb(51 , 51 , 51); font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">}</span></div>
<div class="crayon-line crayon-striped-line" id="crayon-5a7af22005fda373078428-8" style="background: rgb(247, 247, 247) !important; border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span style="color: #cc0000; font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit;"><br /></span>
<span style="color: #cc0000; font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit;">call this extension in your code</span></div>
<div class="crayon-line crayon-striped-line" id="crayon-5a7af22005fda373078428-8" style="background: rgb(247, 247, 247) !important; border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;"><span class="Apple-converted-space">CGFloat Text</span>Height = (Text</span><span style="font-family: inherit; font-size: inherit; font-style: inherit;">Label</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">.</span><span class="s2" style="font-family: inherit; font-size: inherit; font-style: inherit;">text</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">?.</span><span class="s3" style="font-family: inherit; font-size: inherit; font-style: inherit;">heightWithConstrainedWidth</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">(width:</span><br />
<span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">Text</span><span style="font-family: inherit; font-size: inherit; font-style: inherit;">Label</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">.</span><span class="s2" style="font-family: inherit; font-size: inherit; font-style: inherit;">frame</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">.</span><span class="s2" style="font-family: inherit; font-size: inherit; font-style: inherit;">size</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">.</span><span class="s2" style="font-family: inherit; font-size: inherit; font-style: inherit;">width</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">, font: </span><span style="font-family: inherit; font-size: inherit; font-style: inherit;">TextLabel</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">.</span><span class="s2" style="font-family: inherit; font-size: inherit; font-style: inherit;">font</span><span class="s1" style="font-family: inherit; font-size: inherit; font-style: inherit;">))!</span></div>
<div class="crayon-line crayon-striped-line" id="crayon-5a7af22005fda373078428-8" style="background: rgb(247, 247, 247) !important; border: 0px; box-sizing: inherit; font-family: Monaco, MonacoRegular, "Courier New", monospace; font-size: 12px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-sy" style="border: 0px; box-sizing: inherit; font-family: inherit; font-size: inherit; font-style: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">
<span style="color: #333333; font-weight: inherit;">
</span><div class="p2" style="color: #333333; font-weight: inherit;">
<span class="Apple-converted-space"> </span></div>
<span style="color: #333333;">
</span><span style="color: #333333; font-weight: inherit;">
</span></span></div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-89086949435622877972016-08-20T07:43:00.000-07:002016-08-20T07:43:13.874-07:00iPhone Bluetooth Objective - C Programming<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 class="post-title entry-title" itemprop="name" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, sans-serif; margin: 20px 0px 0px; position: relative;">
<br /></h3>
<div class="post-body entry-content" id="post-body-8026897393285217588" itemprop="description articleBody" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, sans-serif; font-size: 13px; line-height: 18.2px; position: relative; width: 590px;">
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">Using Xcode, create a new View-based Application project and name it as Bluetooth.</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">All the various APIs for accessing the Bluetooth is located in the GameKit framework. Hence, you need to add this framework to your project. Add a new Framework to the project by right-clicking on the Frameworks group in Xcode and selecting Add, Existing Frameworks. Select GameKit.framework</span></div>
<table align="right" border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="width: 239px;"><tbody>
<tr><td style="padding: 3.75pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0in;">
<br /></div>
</td><td style="padding: 3.75pt; width: 9pt;" width="12"><div class="MsoNormal" style="margin-bottom: 0in;">
<br /></div>
</td></tr>
<tr><td style="padding: 3.75pt;"><div class="MsoNormal" style="margin-bottom: 0in;">
<br /></div>
</td><td style="padding: 3.75pt;"><div class="MsoNormal" style="margin-bottom: 0in;">
<br /></div>
</td></tr>
</tbody></table>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">In the </span><span style="font-family: "Courier New"; font-size: 10pt;">BluetoothViewController.h</span><span style="font-family: "Times New Roman", serif; font-size: 12pt;"> file, declare the following object, outlets, and actions:</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">#import</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">#import</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@interface BluetoothViewController : UIViewController {</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">GKSession *currentSession;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">IBOutlet UITextField *txtMessage;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">IBOutlet UIButton *connect;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">IBOutlet UIButton *disconnect;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@property (nonatomic, retain) GKSession *currentSession;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@property (nonatomic, retain) UITextField *txtMessage;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@property (nonatomic, retain) UIButton *connect;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@property (nonatomic, retain) UIButton *disconnect;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">-(IBAction) btnSend:(id) sender;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">-(IBAction) btnConnect:(id) sender;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">-(IBAction) btnDisconnect:(id) sender;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@end</span></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">The GKSession object is used to represent a session between two connected Bluetooth devices. You will make use of it to send and receive data between the two devices.</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">In the </span><span style="font-family: "Courier New"; font-size: 10pt;">BluetoothViewController.m</span><span style="font-family: "Times New Roman", serif; font-size: 12pt;"> file, add in the following statements in bold:</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">#import "BluetoothViewController.h"</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@implementation BluetoothViewController</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@synthesize currentSession;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@synthesize txtMessage;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@synthesize connect;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@synthesize disconnect;</span></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">Double-click on </span><span style="font-family: "Courier New"; font-size: 10pt;">BluetoothViewController.xib</span><span style="font-family: "Times New Roman", serif; font-size: 12pt;"> to edit it in Interface Builder. Add the following views to the View window</span></div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;" type="disc">
<li class="MsoNormal" style="line-height: normal; margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: "Times New Roman", serif; font-size: 12pt;">Text Field</span></li>
<li class="MsoNormal" style="line-height: normal; margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: "Times New Roman", serif; font-size: 12pt;">Round Rect Button</span></li>
</ul>
<table align="right" border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="width: 239px;"><tbody>
<tr><td style="padding: 3.75pt;" valign="top"><br /></td><td style="padding: 3.75pt; width: 9pt;" width="12"><br /></td></tr>
<tr><td style="padding: 3.75pt;"><br /></td><td style="padding: 3.75pt;"><br /></td></tr>
</tbody></table>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">Perform the following actions:</span></div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;" type="disc">
<li class="MsoNormal" style="line-height: normal; margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: "Times New Roman", serif; font-size: 12pt;">Control-click on the File’s Owner item and drag and drop it over the Text Field view. Select txtMessage.</span></li>
<li class="MsoNormal" style="line-height: normal; margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: "Times New Roman", serif; font-size: 12pt;">Control-click on the File’s Owner item and drag and drop it over the Connect button. Select connect.</span></li>
<li class="MsoNormal" style="line-height: normal; margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: "Times New Roman", serif; font-size: 12pt;">Control-click on the File’s Owner item and drag and drop it over the Disconnect button. Select disconnect.</span></li>
<li class="MsoNormal" style="line-height: normal; margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: "Times New Roman", serif; font-size: 12pt;">Control-click on the Send button and drag and drop it over the File’s Owner item. Select btnSend:.</span></li>
<li class="MsoNormal" style="line-height: normal; margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: "Times New Roman", serif; font-size: 12pt;">Control-click on the Connect button and drag and drop it over the File’s Owner item. Select btnConnect:.</span></li>
<li class="MsoNormal" style="line-height: normal; margin: 0px 0px 0.25em; padding: 0px;"><span style="font-family: "Times New Roman", serif; font-size: 12pt;">Control-click on the Disconnect button and drag and drop it over the File’s Owner item. Select btnDisconnect:.</span></li>
</ul>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">Right-click on the File’s Owner item to verify that all the connections are made correctly.</span></div>
<table align="right" border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="width: 239px;"><tbody>
<tr><td style="padding: 3.75pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0in;">
<br /></div>
</td><td style="padding: 3.75pt; width: 9pt;" width="12"><div class="MsoNormal" style="margin-bottom: 0in;">
<br /></div>
</td></tr>
<tr><td style="padding: 3.75pt;"><div class="MsoNormal" style="margin-bottom: 0in;">
<br /></div>
</td><td style="padding: 3.75pt;"><div class="MsoNormal" style="margin-bottom: 0in;">
<br /></div>
</td></tr>
</tbody></table>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">Back in Xcode, in the </span><span style="font-family: "Courier New"; font-size: 10pt;">BluetoothViewController.m</span><span style="font-family: "Times New Roman", serif; font-size: 12pt;">file, add in the following statements in bold:</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">- (void)viewDidLoad {</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[connect setHidden:NO];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[disconnect setHidden:YES];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[super viewDidLoad];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">- (void)dealloc {</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[txtMessage release];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[currentSession release];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[super dealloc];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">}</span></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<b><span style="font-family: "Times New Roman", serif; font-size: 13.5pt;">Searching for Peer Devices</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">Now that all the plumbings for the project have been done, you can now focus on the APIs for accessing other Bluetooth devices.</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">In the </span><span style="font-family: "Courier New"; font-size: 10pt;">BluetoothViewController.h</span><span style="font-family: "Times New Roman", serif; font-size: 12pt;"> file, declare a </span><span style="font-family: "Courier New"; font-size: 10pt;">GKPeerPickerController</span><span style="font-family: "Times New Roman", serif; font-size: 12pt;"> object:</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">#import "BluetoothViewController.h"</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">#import</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@implementation BluetoothViewController</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@synthesize currentSession;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@synthesize txtMessage;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@synthesize connect;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">@synthesize disconnect;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">GKPeerPickerController *picker;</span></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">The </span><span style="font-family: "Courier New"; font-size: 10pt;">GKPeerPickerController</span><span style="font-family: "Times New Roman", serif; font-size: 12pt;"> class provides a standard UI to let your application discover and connect to another Bluetooth device. This is the easiest way to connect to another Bluetooth device.</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: "Times New Roman", serif; font-size: 12pt;">To discover and connect to another Bluetooth device, implement the </span><span style="font-family: "Courier New"; font-size: 10pt;">btnConnect:</span><span style="font-family: "Times New Roman", serif; font-size: 12pt;"> method as follows:</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">-(IBAction) btnConnect:(id) sender {</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">picker = [[GKPeerPickerController alloc] init];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">picker.delegate = self;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[connect setHidden:YES];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[disconnect setHidden:NO];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">[picker show];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="font-family: "Courier New"; font-size: 10pt;">}</span></div>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable"><tbody>
<tr><td style="padding: 0in;"><table border="0" cellpadding="0" class="MsoNormalTable" style="width: 6px;"><tbody>
<tr><td style="padding: 0.75pt;" valign="top"><br /></td></tr>
</tbody></table>
</td></tr>
</tbody></table>
</div>
When remote Bluetooth devices are detected and the user has selected and connected to one of them, the <tt><span style="font-size: 10pt;">peerPickerController:didConnectPeer:toSession:</span></tt> method will be called. Hence, implement this method as follows:<br /><pre><code> </code></pre>
<pre><code>- (void)peerPickerController:(GKPeerPickerController *)picker</code></pre>
<pre><code>didConnectPeer:(NSString *)peerID</code></pre>
<pre><code>toSession:(GKSession *) session {</code></pre>
<pre><code>self.currentSession = session;</code></pre>
<pre><code>session.delegate = self;</code></pre>
<pre><code>[session setDataReceiveHandler:self withContext:nil];</code></pre>
<pre><code>picker.delegate = nil;</code></pre>
<pre><code>[picker dismiss];</code></pre>
<pre><code>[picker autorelease];</code></pre>
<pre><code>}</code></pre>
When the user has connected to the peer Bluetooth device, you save the GKSession object to the currentSession property. This will allow you to use the GKSession object to communicate with the remote device.<br />If the user cancels the Bluetooth Picker, the <tt><span style="font-size: 10pt;">peerPickerControllerDidCancel:</span></tt> method will be called. Define this method as follows:<br /><pre><code> </code></pre>
<pre><code>- (void)peerPickerControllerDidCancel:(GKPeerPickerController *)picker</code></pre>
<pre><code>{</code></pre>
<pre><code>picker.delegate = nil;</code></pre>
<pre><code>[picker autorelease];</code></pre>
<pre><code>[connect setHidden:NO];</code></pre>
<pre><code>[disconnect setHidden:YES];</code></pre>
<pre><code>}</code></pre>
<br /><br />To disconnect from a connected device, use the <tt><span style="font-size: 10pt;">disconnectFromAllPeers</span></tt> method from the GKSession object. Define the <tt><span style="font-size: 10pt;">btnDisconnect:</span></tt> method as follows:<br /><pre><code> </code></pre>
<pre><code>-(IBAction) btnDisconnect:(id) sender {</code></pre>
<pre><code>[self.currentSession disconnectFromAllPeers];</code></pre>
<pre><code>[self.currentSession release];</code></pre>
<pre><code>currentSession = nil;</code></pre>
<pre><code>[connect setHidden:NO];</code></pre>
<pre><code>[disconnect setHidden:YES];</code></pre>
<pre><code>}</code></pre>
When a device is connected or disconnected, the <tt><span style="font-size: 10pt;">session:peer:didChangeState:</span></tt> method will be called. Implement the method as follows:<br /><pre><code> </code></pre>
<pre><code>- (void)session:(GKSession *)session</code></pre>
<pre><code>peer:(NSString *)peerID</code></pre>
<pre><code>didChangeState:(GKPeerConnectionState)state {</code></pre>
<pre><code>switch (state)</code></pre>
<pre><code>{</code></pre>
<pre><code>case GKPeerStateConnected:</code></pre>
<pre><code>NSLog(@"connected");</code></pre>
<pre><code>break;</code></pre>
<pre><code>case GKPeerStateDisconnected:</code></pre>
<pre><code>NSLog(@"disconnected");</code></pre>
<pre><code>[self.currentSession release];</code></pre>
<pre><code>currentSession = nil;</code></pre>
<pre><code>[connect setHidden:NO];</code></pre>
<pre><code>[disconnect setHidden:YES];</code></pre>
<pre><code>break;</code></pre>
<pre><code>}</code></pre>
<pre><code>}</code></pre>
Handling this event will allow you to know when a connection is established, or ended. For example, when the connection is established, you might want to immediately start sending data over to the other device.<br /><table align="right" border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="width: 239px;"><tbody>
<tr><td style="padding: 3.75pt;" valign="top"><div class="MsoNormal">
<br /></div>
</td><td style="padding: 3.75pt; width: 9pt;" width="12"><div class="MsoNormal">
<br /></div>
</td></tr>
<tr><td style="padding: 3.75pt;"><div class="MsoNormal">
<br /></div>
</td><td style="padding: 3.75pt;"><div class="MsoNormal">
<br /></div>
</td></tr>
</tbody></table>
<h3 style="margin: 0px; position: relative;">
Sending Data</h3>
To send data to the connected Bluetooth device, use the<tt><span style="font-size: 10pt;">sendDataToAllPeers:</span></tt> method of the GKSession object. The data that you send is transmitted via an NSData object; hence you are free to define your own application protocol to send any types of data (e.g. binary data such as images). Define the<tt><span style="font-size: 10pt;">mySendDataToPeers:</span></tt> method as follows:<br /><pre><code> </code></pre>
<pre><code>- (void) mySendDataToPeers:(NSData *) data</code></pre>
<pre><code>{</code></pre>
<pre><code>if (currentSession)</code></pre>
<pre><code>[self.currentSession sendDataToAllPeers:data</code></pre>
<pre><code>withDataMode:GKSendDataReliable</code></pre>
<pre><code>error:nil];</code></pre>
<pre><code>}</code></pre>
Define the <tt><span style="font-size: 10pt;">btnSend:</span></tt> method as follows so that the text entered by the user will be sent to the remote device:<br /><pre><code> </code></pre>
<pre><code>-(IBAction) btnSend:(id) sender</code></pre>
<pre><code>{</code></pre>
<pre><code>//---convert an NSString object to NSData---</code></pre>
<pre><code>NSData* data;</code></pre>
<pre><code>NSString *str = [NSString stringWithString:txtMessage.text];</code></pre>
<pre><code>data = [str dataUsingEncoding: NSASCIIStringEncoding];</code></pre>
<pre><code>[self mySendDataToPeers:data];</code></pre>
<pre><code>}</code></pre>
<h3 style="margin: 0px; position: relative;">
Receiving Data</h3>
<table align="right" border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="width: 239px;"><tbody>
<tr><td style="padding: 3.75pt;" valign="top"><div class="MsoNormal">
<br /></div>
</td><td style="padding: 3.75pt; width: 9pt;" width="12"><div class="MsoNormal">
<br /></div>
</td></tr>
<tr><td style="padding: 3.75pt;"><div class="MsoNormal">
<br /></div>
</td><td style="padding: 3.75pt;"><div class="MsoNormal">
<br /></div>
</td></tr>
</tbody></table>
When data is received from the other device, the<tt><span style="font-size: 10pt;">receiveData:fromPeer:inSession:context:</span></tt>method will be called. Implement this method as follows:<br /><pre><code> </code></pre>
<pre><code>- (void) receiveData:(NSData *)data</code></pre>
<pre><code>fromPeer:(NSString *)peer</code></pre>
<pre><code>inSession:(GKSession *)session</code></pre>
<pre><code>context:(void *)context {</code></pre>
<pre><code>//---convert the NSData to NSString---</code></pre>
<pre><code>NSString* str;</code></pre>
<pre><code>str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];</code></pre>
<pre><code>UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Data received"</code></pre>
<pre><code>message:str</code></pre>
<pre><code>delegate:self</code></pre>
<pre><code>cancelButtonTitle:@"OK"</code></pre>
<pre><code>otherButtonTitles:nil];</code></pre>
<pre><code>[alert show];</code></pre>
<pre><code>[alert release];</code></pre>
<pre><code>}</code></pre>
Here, the received data is in the NSData format. To display it using the UIAlertView class, you need to convert it to an NSString object.<br /><div class="MsoNormal">
<br /></div>
<h3 style="margin: 0px; position: relative;">
Testing the Application</h3>
<br /><table align="RIGHT" border="0" cellpadding="5" cellspacing="0" style="width: 239px;"><tbody>
<tr><td valign="top"><br /></td><td width="12"></td></tr>
<tr><td class="smallfont"><a href="http://www.blogger.com/blogger.g?blogID=6589214000958721888" style="color: #436590; text-decoration: none;"><b></b></a></td></tr>
</tbody></table>
That’s it!<br />You are now ready to test the application. Press Command-R in Xcode to deploy the application onto two iPhones / iPod Touches. For this article, I assume you have two devices -- either iPhones or iPod Touches. In order to run this application, they both need to run at least iPhone OS 3.0.<br />Once the application is deployed to the two devices, launch the application on both devices. On each device, tap the Connect button. The GKPeerPickerController will display the standard UI to discover other devices .<br />After a while, both application should be able to find each other When you tap on the name of the found device, the application will attempt to connect to it. </div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-43536166215488135742016-08-20T07:41:00.000-07:002016-08-20T07:41:33.807-07:00Steps to follow to submitting iPhone/iPad Apps To The Apple App Store<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 class="post-title entry-title" itemprop="name" style="background-color: white; margin: 20px 0px 0px; position: relative;">
<br /></h3>
<div class="post-header" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, sans-serif; font-size: 13px; line-height: 1.6; margin: 0px 0px 1em;">
<div class="post-header-line-1">
</div>
</div>
<div class="post-body entry-content" id="post-body-3184925762100572024" itemprop="description articleBody" style="background-color: white; color: #666666; font-family: "Trebuchet MS", Trebuchet, sans-serif; font-size: 13px; line-height: 18.2px; position: relative; width: 590px;">
<div dir="ltr" trbidi="on">
<div style="color: blue;">
<strong>Step 1:</strong></div>
<br />Certificate is an essential element to submit or test an application on iPhone. It comes with code sign(Signatures) which would verified when an application is submitted on apple store or when tested on iPhone.<br /><em>One can bypass these if an application is installed on jail-break iPhone or when submitted on Cydia but this is not possible when one wants submit it to AppStore.</em><br /><br />One has to through 2 step procedure to create a certificate from developer portal. I copied those two from “iPhone developer portal”<br /><ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Generating Certificate Signing Request</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Submitting a Certificate Signing Request for Approval</li>
</ul>
<div>
<strong>Generating a Certificate Signing Request</strong>:</div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>Open the Utilities folder and launch Key chain Access from the Applications folder.</li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Set the value of Online Certificate Status Protocol (OCSP) and Certificate Revocation List (CRL) to “off” in the Preferences Menu.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Select Key chain Access -> Certificate Assistant -> Request a Certificate from a Certificate Authority.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Fill in your email address in User Email Address Field. Confirm that this email address is same as provided at the time of registering as iPhone developer.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Fill in your name in the Common Name field. Confirm that this name is same as provided at the time of registering as iPhone developer.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>It is not necessary to have an Certificate Authority (CA). The ‘Required’ message would be eliminated after finishing the following step.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>Click the ‘save to disk’ radio button if prompted, choose ‘Let me specify key pair information’ and proceed.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>If you choose ‘Let me specify key pair’ option then one has provide a file name and click ‘Save’. Select ‘2048 bits’ for Key Size and ‘RSA’ for the algorithm in next screen and proceed.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> CSR file would created on the desktop by Certificate Authority.</li>
</ul>
<div>
<strong>Submitting a Certificate Signing Request for Approval:</strong></div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>Once CSR file is created log in to the iPhone developer program portal and go to ‘Certificates’> ‘Development’ and select ‘Add Certificate’.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Click the ‘Choose file’ button, select your CSR and click ‘Submit’. The portal will reject the CSR if Key Size is not set to 2048 bit at the time of CSR creation.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>This will followed by notification to Team Admins by email of the certificate request.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>The change in the certificate status would informed by email on approval or rejection of the CSR by Team Admin.</li>
</ul>
<div>
<strong>Download/Installing Certificate on your machine</strong></div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Once the CSR is approved the Team Members and Team Admins can download their certificates via the ‘Certification’ section of the Program Portal. Choose ‘Download’ next to the certificate name to download your iPhone development certificate to your local machine.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>Once this is done double-click the <em>.cer</em> file to launch Key chain Access and install your certificate.</li>
</ul>
On installation of certificate on your MAC the next step is to create an App ID.<br /><br /><br /><div style="color: blue;">
<strong> </strong><strong>Step 2:</strong></div>
<br /><div>
<strong>Follow the following steps to create an App ID:</strong></div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>Go to ‘App IDs’ and click ‘App ID’ after logging in to iPhone developer program portal.</li>
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Populate the ‘App Id Name’ field with your application name (that is – iPhone app) and in ‘App Id’ enter something like <em>com.yourdomain.applicationname</em> (i.e<em>com.companyname.iPhoneapp</em>) and click submit.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>Please do note down the “App Id” as this would be utilized in Info.plist, bundle identifier tag.</li>
</ul>
<div style="color: blue;">
<strong> </strong><strong>Step 3<strong>:</strong></strong></div>
<br /><div>
<strong>Next step would be to create a Provisioning file for our X code and is the last step for creating binary which would submit it to App Store.</strong></div>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>After you navigate to ‘Provisioning’> ‘Distribution’ click ‘Add Profile’ in iPhone developer program portal.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Choose “App Store” in “Distribution Method”.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>In “Profile Name” enter your application name (i.e iPhone app) which will be your provisioning profile name as well.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>In “App ID” select the app name(i.e. iPhone app) which you created in Step 2.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>After downloading the Provisioning profile copy it to your/YourUserName/Library/MobileDevice/Provisioning Profile.</li>
</ul>
<strong><strong></strong></strong><strong style="color: blue;">Step 4:</strong><br /><br />Now everything is step up, open your project in Xcode<br /><ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>Click “i” Info button after selecting your project from “Group & File” in left side bar.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Navigate to “Configuration” tab and select “Release”. Click the “Duplicate” button from bottom, name is “iPhone Distribution”.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Click on “Build” tab and choose “iPhone Distribution” and enter in “Search in Build Settings” filed ‘Base SDK’ and select the current selected Device and change to what gadget your application is targeting.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>Now in “Search in build setting” field enter “code signing identity” and choose the provisioning profile created earlier in Step 3. Apply the same to the child property “Any iPhone OS Device”.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>Once this done close the Info screen and select the “Target”> “Your App” from “Group & File” in left side bar and click on “Info” button again from X code.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong> </strong>To be on the safer side repeat step 3 and 4.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> With the Info screen still open click on “Properties” tab and enter “App Id”(<em>i.e. com.companyname.iPhoneapp</em>) in Identifier field.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> Now that all is done, click on “Build” (cmd+B) from X code>Build.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong> You will find your binary file created on right clicking on “Product”> “YourApp” and selecting “Reveal in Finder”. Zip this file.</li>
</ul>
<div style="color: blue;">
<strong>Step 5<strong><strong><strong>:</strong></strong></strong></strong></div>
<br />The next step is to submit the binary file created to iTunes connect.<br /><ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>In your browser type <em>https://itunesconnect.apple.com/</em> and login using your iPhone developer account.</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>Click on “Manage Your Account” > “Add Application”</li>
</ul>
<ul style="line-height: 1.4; margin: 0.5em 0px; padding: 0px 2.5em;">
<li style="margin: 0px 0px 0.25em; padding: 0px;"><strong></strong>On replying to a simple question from apple you can submit your application to app store. You also need few things in your system before you submit your application.</li>
</ul>
<strong>a)</strong> Application Name (must be unique)<br /><strong>b)</strong> Application description<br /><strong>c) </strong>Application Category<br /><strong>d)</strong> URL for your application feedback.<br /><strong>e) </strong>Icon of your application in 512 x 512 size.<br /><strong>f)</strong> Main picture of your application in 320 x 480 or 320 x 460 size.<br />(You have option to submit up to 4 more pictures of your application).</div>
</div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-79680313862738848552014-09-17T03:10:00.000-07:002014-09-17T03:12:52.496-07:00you should know what is the use of @property.<div dir="ltr" style="text-align: left;" trbidi="on">
<ul style="text-align: left;">
<li><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"> </span></span></span></span></span></span></span></span><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value">@property<i> offers a way to define the information that a class is intended to encapsulate. If you declare an object/variable using </i><i>@property</i><i>, then that object/variable will be accessible to other classes importing its class.</i></span></span></span></span></span></span></span></span><i> </i><br />
<br />
<i>If you declare an object using </i><i>@property</i><i> in the header file, then you have to synthesize it using </i><i>@synthesize</i><i> in the implementation file. </i><br />
<br />
<i><b><i>Example:</i></b><br />.h class</i><br />
<table class="codeblocktable" style="margin-left: 0px; margin-right: auto; text-align: left;"><tbody>
<tr><td class="linenos"><pre></pre>
</td><td class="code"><div class="codeblock">
<pre><span class="">@interface ExampleClass : NSObject</span></pre>
</div>
<div class="codeblock">
<pre><span class="">@property (nonatomic, retain) NSString *name;</span></pre>
</div>
<div class="codeblock">
<pre><span class="">@end</span></pre>
</div>
</td></tr>
</tbody></table>
<br />.m class<table class="codeblocktable" style="margin-left: 0px; margin-right: auto; text-align: left;"><tbody>
<tr><td class="linenos"><pre></pre>
</td><td class="code"><div class="codeblock">
<pre><span class="">@implementation ExampleClass</span></pre>
</div>
<div class="codeblock">
<pre><span class="">@synthesize name;</span></pre>
</div>
<div class="codeblock">
<pre><span class="">@end</span></pre>
</div>
</td></tr>
</tbody></table>
<br />Now the compiler will synthesize accessor methods for <b>name</b>.</li>
<li><table class="codeblocktable" style="margin-left: 0px; margin-right: auto; text-align: left;"><tbody>
<tr><td class="linenos"></td><td class="code"><div class="codeblock">
<pre><span class="">ExampleClass *newObject=[[ExampleClass alloc]init];</span></pre>
</div>
<div class="codeblock">
<pre><span class="">NSString *name1=[newObject name]; // get 'name'</span></pre>
</div>
<div class="codeblock">
<pre><span class="">[obj setName:@“Tiger”];</span></pre>
</div>
</td></tr>
</tbody></table>
<br />
<ul>
<li>List of attributes of <b>@property :</b></li>
<li><ul>
<li><b>atomic. </b></li>
<li><b>nonatomic.</b></li>
<li><b>retain.</b></li>
<li><b>copy.</b></li>
<li><b>readonly.</b></li>
<li><b>readwrite.</b></li>
<li><b>assign.</b></li>
<li><b>strong.</b></li>
<li><b> </b></li>
</ul>
</li>
</ul>
<b>atomic : </b>
It is the default behaviour. If an object is declared as atomic then it
becomes thread-safe. Thread-safe means, at a time only one thread of a
particular instance of that class can have the control over that object.<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"><br /><table class="codeblocktable"><tbody>
<tr><td class="linenos"><pre>
</pre>
</td><td class="code"><div class="codeblock">
<pre><span class="">Example : </span></pre>
</div>
<div class="codeblock">
<pre><span class="">@property NSString *name; //by default atomic</span></pre>
</div>
<div class="codeblock">
<pre><span class="">@property (atomic)NSString *name; // explicitly declared atomic</span></pre>
</div>
</td></tr>
</tbody></table>
</span></span></span></span><b>nonatomic:</b>
It is not thread-safe. You can use the nonatomic property attribute to
specify that synthesized accessors simply set or return a value
directly, with no guarantees about what happens if that same value is
accessed simultaneously from different threads. For this reason, it’s
faster to access a nonatomic property than an atomic one.<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"> </span></span></span></span><br />
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value">@property (nonatomic)NSString *name; </span></span></span></span><br />
<ul>
<li><b>retain:</b>
is required when the attribute is a pointer to an object.The setter
method will increase retain count of the object, so that it will occupy
memory in autorelease pool.</li>
</ul>
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value">@property (retain)NSString *name;</span></span></span></span></span></span></span><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"><br /><ul>
<li><b>copy:</b> If you use copy, you can't use retain. Using copy instance of the class will contain its own copy.</li>
</ul>
Even
if a mutable string is set and subsequently changed, the instance
captures whatever value it has at the time it is set. No setter and
getter methods will be synthesized.<br /><table class="codeblocktable"><tbody>
<tr><td class="linenos"><pre>
</pre>
</td><td class="code"><div class="codeblock">
<pre><span class="">@property (copy) NSString *name;
</span></pre>
</div>
<div class="codeblock">
<pre><span class="">NSMutableString *nameString = [NSMutableString stringWithString:@"Liza"]; </span></pre>
</div>
<div class="codeblock">
<pre><span class="">xyzObj.name = nameString; </span></pre>
</div>
<div class="codeblock">
<pre><span class="">[nameString appendString:@"Pizza"];</span></pre>
</div>
</td></tr>
</tbody></table>
</span></span></span></span></span></span></span><br />
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"><b> </b></span></span></span></span><b>readonly:</b> If you don't want to allow the property to be changed via setter method, you can declare the property readonly.<br /><pre><span class="">@property (readonly) NSString *name;</span></pre>
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"><ul>
<li><b>readwrite:</b> is the default behaviour. You don't need to specify readwrite attribute explicitly.</li>
</ul>
</span></span></span></span><div style="margin-left: 40px;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"></span></span></span></span><br />
<div class="codeblock inline_codeblock">
<pre><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"><span class="">@property (readwrite) NSString *name;</span></span></span></span></span></pre>
</div>
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value">
</span></span></span></span></div>
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value">
</span></span></span></span><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"><ul>
<li><b>assign:</b>
will generate a setter which assigns the value to the instance variable
directly, rather than copying or retaining it. This is best for
primitive types like NSInteger and CGFloat, or objects you don't
directly own, such as delegates.</li>
</ul>
</span></span></span></span><div style="margin-left: 40px;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"></span></span></span></span><br />
<div class="codeblock inline_codeblock">
<pre><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"><span class="">@property (assign) NSInteger year;</span></span></span></span></span></pre>
</div>
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value">
</span></span></span></span></div>
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value">
</span></span></span></span><br />
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"><b>Strong:-</b></span></span></span></span>is a replacement for retain.<br />
<span id="ld_loxrju_145818"><span class="inline_editor_value"></span></span><br />
<div class="codeblock inline_codeblock" style="margin-left: 40px;">
<pre><span class="">@property (nonatomic, strong) AVPlayer *player;</span></pre>
</div>
</li>
</ul>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value">The
strong keyword implies ownership of the property. This is the default,
so you don't have to explicitly use the keyword if you intend for the
property to have a strong reference. If you declare a property as
strong, that property will stay in memory as long as at least one object
has a strong reference to it.</span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"></span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"></span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"></span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"></span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"></span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"></span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"><br /></span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"><b>Weak:- </b></span></span></span></span></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"></span></span></span></span><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value">The weak keyword implies no
ownership or responsibility. If you declare a property as weak, it will
be released if the object has no strong references to it. Assigning an
object to a weak property does not increase the retain count of that
object as it would if the property were declared as strong.</span></span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_cSefJEt_toggle_link"><span id="ld_iqteha_134239"><span id="ld_iqteha_134240"><span class="inline_editor_value"></span></span></span></span><span href="http://www.quora.com/What-is-the-difference-between-strong-retain-nonatomic-etc-in-objective-C-iOS-property#" id="__w2_kfUg9QW_toggle_link"><span id="ld_loxrju_145817"><span id="ld_loxrju_145818"><span class="inline_editor_value"></span></span></span></span></div>
<ul style="text-align: left;">
<li><b>unsafe_unretained:</b>
There are a few classes in Cocoa and Cocoa Touch that don’t yet support
weak references, which means you can’t declare a weak property or weak
local variable to keep track of them. These classes include NSTextView,
NSFont and NSColorSpace,etc. If you need to use a weak reference to one
of these classes, you must use an unsafe reference.</li>
</ul>
<div style="text-align: left;">
An unsafe reference is similar to a weak reference in that it doesn’t keep its related object alive, but it won’t be set to <b>nil</b> if the destination object is deallocated.</div>
<div class="codeblock inline_codeblock" style="text-align: left;">
<pre><span class="">@property (unsafe_unretained) NSObject *unsafeProperty;</span></pre>
</div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-48823940740941453852014-09-02T03:37:00.003-07:002014-09-02T03:37:18.620-07:00Filtering a NSArray using NSPredicate <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana,sans-serif;">In this post, i'll walk you through how to filter an NSArray using NSPredicates. </span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">The first thing you'll need to decide is if you're filtering a number or a string.</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">For strings, you can use any of the following filters: (NOTE: must be all caps)</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><ul>
<li><span style="font-family: Verdana,sans-serif;">BEGINSWITH</span></li>
<li><span style="font-family: Verdana,sans-serif;">ENDSWITH</span></li>
<li><span style="font-family: Verdana,sans-serif;">LIKE</span></li>
<li><span style="font-family: Verdana,sans-serif;">MATCHES</span></li>
<li><span style="font-family: Verdana,sans-serif;">CONTAINS</span></li>
</ul>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">For numbers, you can use:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><ul>
<li><span style="font-family: Verdana,sans-serif;">!=</span></li>
<li><span style="font-family: Verdana,sans-serif;">></span></li>
<li><span style="font-family: Verdana,sans-serif;">>=</span></li>
<li><span style="font-family: Verdana,sans-serif;"><</span></li>
<li><span style="font-family: Verdana,sans-serif;"><=</span></li>
<li><span style="font-family: Verdana,sans-serif;">==</span></li>
</ul>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Now that you know what kind of data you're going to filter on, we can build our predicate.</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div style="text-align: left;">
<span style="font-family: Verdana,sans-serif;">Lets first assume we're filtering an array of strings:</span></div>
<div style="text-align: left;">
<br /></div>
<div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSArray* data = @[@"Grapes", @"Apples", @"Oranges];</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Using this array, lets filter on the letter "a"</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">This means we'll want to use CONTAINS.</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">So if we want to build a hard-coded string it would look something like:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSString* filter = @"%K CONTAINS %@";</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">We'll then take our filter string and create a predicate with it: </span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSPredicate* predicate = [NSPredicate predicateWithFormat:filter, @"SELF", @"a"];</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Now we can get our filtered out data:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSArray* filteredData = [data filteredArrayUsingPredicate:predicate];</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">The result will be an array that contains 2 values:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">"Grapes" and "Oranges"</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Hmm.... why wasn't "Apples" included, it clearly contains the letter "a". </span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Well, b/c the "a" is a capital "A" it wasn't included. </span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">In order for it to be included, we need to tell the filter to be case insensitive. We do that by passing the parameter "c"</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSString* filter = @"%K CONTAINS[c] %@";</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Now, if we rerun our filter with this new string, there will be 3 values returned.</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Its worth noting that there is one additional parameter you can also
pass in: "d". It stands for diacritic insensitive. So if you wanted your
filter to be both case and diacritic insensitive just use:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSString* filter = @"%K CONTAINS[cd] %@";</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">i'm sure, you may be wondering what the %K is in the filter string
is. That represents the property for each item in the array that we're
filtering on. Because our array is just an array of strings, we're not
filtering on a particular property. So in this case, we're passing in
"SELF". </span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Lets pretend we have a more complex object now. We'll call it Person and it has a property called "firstName".</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">If we wanted to filter on our array of Person objects, we would have to just modify the values we pass in to our predicate:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSPredicate* predicate = [NSPredicate predicateWithFormat:filter, @"firstName", @"a"];</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">When we pass this predicate into filteredArrayUsingPredicate: our
Person array will be filtered with Person objects whose firstName
contains the letter "a".</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">To take this one step further, lets add a lastName property to our Person object. </span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">How do we filter both the firstName and lastName properties at the same time?</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">For this scenario, the requirement is that we want to filter our
Person array by any first or last name that contains the letter a. </span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">To do this, we'll need to use a different method to create our NSPredicate: predicateWithFormat:argumentArray:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">We'll also need a new filter string:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSString* filter = @"%K CONTAINS[cd] %@ || <span>%K CONTAINS[cd] %@</span>";</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Then we need to build an array of arguments. The array is just made
up of all of the arguments that make up the missing fields in the filter
string: </span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSArray* args = @[@"firstName", @"a", @"lastName", @"a"];</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">Finally we can build our predicate:</span><br />
<span style="font-family: Verdana,sans-serif;">
</span><div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;">
<div id="codeSnippet" style="background-color: #f4f4f4; border-style: none; color: black; direction: ltr; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;">
<span style="font-family: Verdana,sans-serif;">NSPredicate* predicate = [NSPredicate predicateWithFormat:filter argumentArray:args];</span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">We can then take that predicate and filter our array the way we did above. </span><br />
<div style="text-align: left;">
<br /></div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-26166572221799115842014-08-30T09:38:00.003-07:002014-08-30T09:38:28.515-07:00what is appDelegate?<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;"><span style="background-color: white; line-height: 20.7999992370605px;">The </span><strong style="background-color: white; line-height: 20.7999992370605px;">AppDelegate</strong><span style="background-color: white; line-height: 20.7999992370605px;"> is sort of like the entry point for your application. It implements </span><strong style="background-color: white; line-height: 20.7999992370605px;">UIApplicationDelegate</strong><span style="background-color: white; line-height: 20.7999992370605px;"> and contains methods that are called when your application launches, when is going to the background (i.e. when you hit the home key), when it’s opened back up, and more. The </span><strong style="background-color: white; line-height: 20.7999992370605px;">AppDelegate</strong><span style="background-color: white; line-height: 20.7999992370605px;"> object is stored as a property on the </span><strong style="background-color: white; line-height: 20.7999992370605px;">UIApplication </strong><span style="background-color: white; line-height: 20.7999992370605px;">class and is accessible from anywhere in your objective-C classes. The header and implementation file for your </span><strong style="background-color: white; line-height: 20.7999992370605px;">AppDelegate</strong><span style="background-color: white; line-height: 20.7999992370605px;"> is generated when you create your project and you don’t have to make any modifications for it to work. However, that doesn’t mean we can’t make changes and make use of the </span><strong style="background-color: white; line-height: 20.7999992370605px;">AppDelegate</strong><span style="background-color: white; line-height: 20.7999992370605px;">. We’re going to keep this simple and just add a new</span><strong style="background-color: white; line-height: 20.7999992370605px;">NSString</strong><span style="background-color: white; line-height: 20.7999992370605px;"> property to the delegate.</span></span><br />
<span style="background-color: white; font-family: Helvetica; font-size: x-small; line-height: 20.7999992370605px;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi7JjheW8KjWWjIKq4SAu6Kc3uP_r_FUcmb1n4GElAsbK4B7lGHHgpJ1pxvd_GG_PeGN8_E6CYX6IZtKSLzX_BCa4o0fgoSV8meKTF9OOF7DgyPHnAgmrayGQr5JJUn_UBLvzI7NOB6F26/s1600/app-view-controller.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi7JjheW8KjWWjIKq4SAu6Kc3uP_r_FUcmb1n4GElAsbK4B7lGHHgpJ1pxvd_GG_PeGN8_E6CYX6IZtKSLzX_BCa4o0fgoSV8meKTF9OOF7DgyPHnAgmrayGQr5JJUn_UBLvzI7NOB6F26/s1600/app-view-controller.jpg" height="239" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCz21Jfx-0PCk5xQau2HArMpPm1O2nlt8tSgHoASXziODhylFMmyU6O-WPgdPoTYM2BwFukq00xQvcAMZTBEYjhvaJWEBu9Cuq7MsuL4OwE50dbWRwJ9KayKSoWPExZRjnDWdeLwi-LnRC/s1600/2564doz1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCz21Jfx-0PCk5xQau2HArMpPm1O2nlt8tSgHoASXziODhylFMmyU6O-WPgdPoTYM2BwFukq00xQvcAMZTBEYjhvaJWEBu9Cuq7MsuL4OwE50dbWRwJ9KayKSoWPExZRjnDWdeLwi-LnRC/s1600/2564doz1.png" height="240" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaUaQmIuSXRL0okn-z4hOaebgTJ8mpEfmffVXxZqHtw8_Ztm9zfZUvIfpojpr3oWQrOqLRbClytY3Y71quXppHsZJw8Pd6PFUXwB5O4zN5E7vMnI8VYP6oY_iQWtrNS3y4ryibg9Mu4zBT/s1600/iban1g.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaUaQmIuSXRL0okn-z4hOaebgTJ8mpEfmffVXxZqHtw8_Ztm9zfZUvIfpojpr3oWQrOqLRbClytY3Y71quXppHsZJw8Pd6PFUXwB5O4zN5E7vMnI8VYP6oY_iQWtrNS3y4ryibg9Mu4zBT/s1600/iban1g.png" height="189" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><span style="background-color: white; line-height: 18px; text-align: justify;">AppDelegate is handling special UIApplication states.</span><span style="background-color: white; line-height: 18px; text-align: justify;">This lets you do initialization/cleanup of your app at the right time.So basically the delegate is responsible for monitoring when it is safe to open/close things, terminate the app etc, and it talks to the application, and gives it accurate & critical information, with regards to how & when to do these tasks?.</span></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
<span style="background-color: white; line-height: 18px; text-align: justify;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div>
<div style="text-align: left;">
<span style="background-color: white; line-height: 18px; text-align: justify;"><span style="font-family: Verdana, sans-serif;">The only way I can imagine it, is a security guard who is called by the staff inside a building, and asked if it is safe to open the security door; he can answer YES or NO</span></span></div>
<div style="text-align: left;">
<span style="background-color: white; line-height: 18px; text-align: justify;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div>
<div style="text-align: left;">
<span style="background-color: white; color: #2c2b2b; line-height: 18px; text-align: justify;"><span style="color: black;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></span></div>
<div style="text-align: left;">
<span style="background-color: white; color: #2c2b2b; line-height: 18px; text-align: justify;"><span style="color: black;"><span style="font-family: Verdana, sans-serif;">1. applicationDidFinishLaunching: – for handling on-startup configuration and construction. which will be called when the app has finished launching</span></span></span></div>
<div style="text-align: left;">
<span style="background-color: white; color: #2c2b2b; line-height: 18px; text-align: justify;"><span style="color: black;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><span style="background-color: white; color: #2c2b2b; line-height: 18px; text-align: justify;"><span style="color: black;">2. applicationWillTerminate: – for cleaning up at the end </span></span><span style="background-color: white; color: #2c2b2b; line-height: 18px; text-align: justify;"><span style="color: black;">You should avoid putting other functionality in the AppDelegate since they don’t really belong there.Many people lump these things into their AppDelegate because they are lazy or they think the AppDelegate controls the whole program. You should avoid centralizing in your AppDelegate since it muddies the areas of concern in the app and doesn’t scale.</span></span></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><span style="background-color: white; color: #2c2b2b; line-height: 18px; text-align: justify;"><span style="color: black;"><br /></span></span></span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="background-color: white; color: #2c2b2b; line-height: 18px; text-align: justify;"><span style="font-family: Verdana, sans-serif;"></span></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><span style="color: black;">a delegate is an object that another object defers to on behavior and informs about changes in its state.</span></span></div>
<span style="font-family: Verdana, sans-serif;"><span style="color: black;"><div style="text-align: left;">
<span style="color: #2c2b2b;"><span style="color: black;">The AppDelegate just sits there doing nothing, waiting to be told that something potentially important will happen. The application/iPhone OS is the one doing the work and calling the AppDelegate and it might want to respond to in your code.</span></span></div>
</span></span></div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-85162621572013377282014-01-14T21:36:00.001-08:002014-09-02T03:41:09.143-07:00 Designated Initializers in Objective - C<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana,sans-serif;"><b style="background-color: rgba(255, 255, 255, 0.882); color: #274e13; line-height: 22.0938px;">Object construction in Objective C is a two phase procedure:---></b></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="background-color: rgba(255, 255, 255, 0.882353); line-height: 22.09375px;"><br /></span></span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="background-color: rgba(255, 255, 255, 0.882353); line-height: 22.09375px;">1. First the object has to be allocated in memory, hence the ‘alloc’ message we always see when a object is invoked this way (and not for example via a ‘get…’, which would be a Factory):</span></span></div>
<span style="font-family: Verdana,sans-serif;"><br /></span>
<span style="font-family: Verdana,sans-serif;"><span style="background-color: rgba(255, 255, 255, 0.882353); line-height: 22.09375px; text-align: justify;">2. Second phase involves object initialization which is quite similar to what would be a constructor in C++. When we implement method ‘init’ (which is just a convention) we have to take care on superclass designated initializer .</span></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="background-color: rgba(255, 255, 255, 0.882353); line-height: 22.09375px;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="background-color: rgba(255, 255, 255, 0.882353); line-height: 22.09375px;"> </span><b style="font-size: 13px; line-height: 14.2969px; text-align: left; white-space: pre;">MyObject* <span style="color: yellow;">obj1</span> = [[MyObject alloc] init];</b></span></div>
<span style="font-family: Verdana,sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 14.296875px; white-space: pre;"><br /></span><b style="line-height: 22.0938px;"><span style="color: #274e13;">Designated initializer :--> </span></b><span style="line-height: 22.09375px;"> Designated initializer is the method that best set up our object between all initializer methods.</span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 14.296875px; white-space: pre;"><br /></span></span>
<span style="font-family: Verdana,sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 14.296875px; white-space: pre;"><br /></span></span>
<br />
<div class="line number1 index0 alt2" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<span style="font-family: Verdana,sans-serif;"><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">- (</code><code class="objc datatypes" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">id</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">) init:</code></b></span></div>
<div class="line number2 index1 alt1" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<span style="font-family: Verdana,sans-serif;"><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">- (</code><code class="objc datatypes" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">id</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">) initWithColor:(</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">NSColor</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">*)color;</code></b></span></div>
<div class="line number3 index2 alt2" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<span style="font-family: Verdana,sans-serif;"><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">- (</code><code class="objc datatypes" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">id</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">) initWithColor:(</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">NSColor</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">*)color andSize:(</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">NSInteger</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">)size;</code></b></span></div>
<div class="line number3 index2 alt2" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><br /></code></span></div>
<div class="line number3 index2 alt2" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><br /></code></span></span></div>
<div class="line number3 index2 alt2" style="-webkit-box-shadow: none !important; background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div style="line-height: 14.2969px; white-space: pre ! important;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">What method do you think is the most complete?</code></span></span></div>
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"></code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><span style="background-color: rgba(255, 255, 255, 0.882); line-height: 1.1em; white-space: pre;">Our third method includes two parameter while the other only one or none.</span></code></span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">Now, we got a pattern that you are going to see every time you implement your own objects:</code></span></span><br />
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
</code></span>
<br />
<div style="font-size: 13px; line-height: 14.2969px; white-space: pre ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><br /></span>
<span style="font-family: Verdana,sans-serif;"><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">- (</code><code class="objc datatypes" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">id</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">) init</code></b></span></div>
</div>
</div>
<div class="line number2 index1 alt1" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><b>{</b></code></span></div>
</div>
<div class="line number3 index2 alt2" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><b><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">if</code> <code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">(</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">self</code> <code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">= [</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">super</code> <code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">init]) {</code></b></span></div>
</div>
<div class="line number4 index3 alt1" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><b>}</b></code></span></div>
</div>
<div class="line number5 index4 alt2" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><b><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">return</code> <code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">self</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">;</code></b></span></div>
</div>
<div class="line number6 index5 alt1" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><b>}</b></code></span></div>
</div>
<div class="line number6 index5 alt1" style="background-color: white ! important; background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 13px; height: auto ! important; left: auto ! important; line-height: 14.2969px; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><br /></code></span></div>
</div>
<div class="line number6 index5 alt1" style="-webkit-box-shadow: none !important; background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div style="font-size: 13px; line-height: 14.2969px; white-space: pre ! important;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"></code><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">This is the most basic method. It neither do variable initialization nor call </code></span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">other initializers. It just call its superclass initializer, check its got a valid</code></span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">pointer back (thus not nil) and return self.</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><span style="background-color: rgba(255, 255, 255, 0.882); line-height: 1.1em; white-space: pre;">But if we got any other initializer </span></code></span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><span style="background-color: rgba(255, 255, 255, 0.882); line-height: 1.1em; white-space: pre;">methods we must call our most complete initializer. This is the designated initializer.</span></code></span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><span style="background-color: rgba(255, 255, 255, 0.882); line-height: 1.1em; white-space: pre;"> So instead of our light ‘init’ tiny method we would have to call initWithColor:andSize:</span></code></span></span></div>
<span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; height: auto ! important; left: auto ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">
</code></span></span>
<br />
<div class="line number1 index0 alt2" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><br /></code></b><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">- (</code><code class="objc datatypes" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">id</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">) init</code></b></code></span></div>
</div>
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"></code><br /></span>
<div class="line number2 index1 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><b>{</b></code></code></span></div>
</div>
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
</code></span>
<div class="line number3 index2 alt2" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><b><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">NSColor</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">* color = [</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">NSColor</code> <code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">greenColor];</code></b></code></span></div>
</div>
<code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line number4 index3 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<b><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">NSInteger</code> <code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">size = 30;</code></b></div>
</div>
<div class="line number5 index4 alt2" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<b><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">return</code> <code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">[</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">self</code> <code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">initWithColor:color andSize:size];</code></b></div>
</div>
<div class="line number6 index5 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><b>}</b></code></div>
</div>
<div class="line number6 index5 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><b><br /></b></code></div>
</div>
<div class="line number6 index5 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><span style="background-color: rgba(255, 255, 255, 0.882353); line-height: 22.09375px; white-space: normal;">and in our initWithColor:andSize:</span></code></div>
</div>
<div class="line number6 index5 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><span style="background-color: rgba(255, 255, 255, 0.882353); line-height: 22.09375px; white-space: normal;"><br /></span></code></div>
</div>
</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;"><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">- (</code><code class="objc datatypes" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">id</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">) initWithColor:(</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">NSColor</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">*)color andSize:(</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">NSInteger</code><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">)size</code></b></code><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"></code><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><div class="line number6 index5 alt1" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"></code><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">{</code></b></code><br />
<code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"></code><br />
<div style="text-align: justify;">
<code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><b><span style="font-size: 16px; line-height: 17.59375px; white-space: pre;"><br /></span></b></code></div>
<code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><b>
</b></code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">if</code><span style="font-family: Verdana,sans-serif;"> </span><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">(</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">self</code><span style="font-family: Verdana,sans-serif;"> </span><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">= [</code><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">super</code><span style="font-family: Verdana,sans-serif;"> </span><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">init]) {</code><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"></code><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"></code><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><b>
</b></code><br />
<div class="line number4 index3 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><b><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">_color = [color retain];</code></b></code></span></div>
</div>
<code class="objc plain" style="-webkit-box-shadow: none !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><b><span style="font-family: Verdana,sans-serif;">
</span><div class="line number5 index4 alt2" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">_size = size;</code></span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">
</span><div class="line number6 index5 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">}</code></span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">
</span><div class="line number7 index6 alt2" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">return</code> <code class="objc keyword" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; color: rgb(0, 102, 153) ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">self</code></span></div>
</div>
<span style="font-family: Verdana,sans-serif;">
</span><span style="font-family: Verdana,sans-serif;">
</span><div class="line number8 index7 alt1" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px 1em ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; white-space: pre ! important; width: auto ! important;">
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><code class="objc plain" style="background-image: none ! important; border-radius: 0px ! important; border: 0px none ! important; bottom: auto ! important; box-shadow: none ! important; box-sizing: content-box ! important; direction: ltr ! important; display: inline ! important; float: none ! important; font-size: 1em ! important; height: auto ! important; left: auto ! important; line-height: 1.1em ! important; margin: 0px ! important; outline: 0px none ! important; overflow: visible ! important; padding: 0px ! important; position: static ! important; right: auto ! important; top: auto ! important; vertical-align: baseline ! important; width: auto ! important;">}</code></span></div>
</div>
</b></code><br />
<div style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; line-height: 1.1em !important; white-space: pre !important;">
</div>
</div>
</code><br />
<div style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 13px; line-height: 14.296875px; white-space: pre !important;">
</div>
</div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-80217241201134202752014-01-14T04:49:00.002-08:002014-01-14T04:54:03.948-08:00Difference Between REST and SOAP Protocols in iPhone<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="p1" style="background-color: white; outline: 0px;">
<span style="font-family: segoe UI;"><span style="color: #274e13; font-weight: bold;">REST :---> </span>Rest stands for Representational State Transfer. It defines a set of architectural principles by which you can design Web Services that focus on a system's resources, including how resource states are addressed and transferred over HTTP by a wide range of clients written in various languages. </span><br />
<span style="font-family: segoe UI;"><br /></span>
<span style="color: #274e13; font-family: segoe UI;"><b>REST has advantages when:---></b></span><br />
<span style="font-family: segoe UI;"><br /></span>
<span style="font-family: segoe UI;">- You have a set of resources that you want to manipulate.</span><br />
<span style="font-family: segoe UI;">- You want to support navigation among resources.</span><br />
<span style="font-family: segoe UI;">- You need scalability. RESTful web services are tyically stateless and therefore easily scalable.</span><br />
<span style="font-family: segoe UI;">- You want to improve performance by caching web service request results at some point between the service and the consumer.</span><br />
<span style="font-family: segoe UI;"><br /></span>
<span style="font-family: segoe UI;"><b><span style="color: #274e13;">SOAP :---></span></b> Soap stands for Simple Object Access Protocol. It is a simple XML-based protocol to let applications exchange information over HTTP.</span><br />
<span style="font-family: segoe UI;"> Or</span><br />
<span style="font-family: segoe UI;">SOAP is a protocol for accessing a Web Service.</span><br />
<span style="font-family: segoe UI;">SOAP is for communication protocol between applications</span><br />
<span style="font-family: segoe UI;">SOAP is a format for sending messages</span><br />
<span style="font-family: segoe UI;">SOAP communicates via the Internet</span><br />
<span style="font-family: segoe UI;">SOAP is platform independent</span><br />
<span style="font-family: segoe UI;">SOAP is language independent</span><br />
<span style="font-family: segoe UI;">SOAP is based on XML</span><br />
<span style="font-family: segoe UI;">SOAP is simple and extensible</span><br />
<span style="font-family: segoe UI;"></span><br />
<span style="font-family: segoe UI;">SOAP allows you to get around firewalls</span></div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-91254960465481245012014-01-13T22:47:00.002-08:002014-01-13T23:03:33.956-08:00difference between copy and retain in ios<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<b><span style="color: #274e13;">copy:</span></b> --> creates a new instance that's a copy of the receiver. It means that you'll have 2 different<br />
<br />
<b><span style="color: #274e13;">retain:</span></b> --> It is done on the created object, and it just increase the reference count.<br />
<br />
NSObject *<span style="color: yellow;">obj1</span> = [[NSObject alloc] init]; // <span style="color: yellow;">obj1</span> has retain count 1<br />
<br />
NSObject *<span style="color: yellow;">obj2</span> = [<span style="color: yellow;">obj1</span> retain]; <br />
<br />
// <span style="color: yellow;">obj1</span> and <span style="color: yellow;">obj2</span> both refer same object. now retain count = 2<br />
<br />
// any change via obj1 will be seen by <span style="color: yellow;">obj2</span> and vice versa, as they point same object<br />
<br />
NSObject *<span style="color: yellow;">obj3</span> = [<span style="color: yellow;">obj1</span> copy]; <br />
<br />
// <span style="color: yellow;">obj3</span> is a separate copy of the object. its retain count is 1 just like newly allocated object<br />
// change via <span style="color: yellow;">obj3 </span>will not affect <span style="color: yellow;">obj1</span> or <span style="color: yellow;">obj2</span> and vice versa as they are separate objects<br />
<br />
<br />
<b><span style="color: #274e13;">Example Code :---></span></b><br />
<br />
@implementation ABC<br />
<br />
-(void) fun1 <br />
{<br />
ObjectA * <span style="color: yellow;">obj1</span> = [[ObjectA alloc] init]; // retainCount = +1<br />
ObjectA * <span style="color: yellow;">obj2</span> = <span style="color: yellow;">obj1</span>; // unchanged<br />
<br />
// you have one instance of `ObjectA` with a retain count of +1<br />
// both `<span style="color: yellow;">obj1</span>` and `<span style="color: yellow;">obj2</span>` point to the same single instance<br />
}<br />
<br />
-(void) fun2 <br />
{<br />
ObjectA * <span style="color: yellow;">obj1</span> = [[ObjectA alloc] init]; // retainCount = +1<br />
ObjectA * <span style="color: yellow;">obj2</span> = [<span style="color: yellow;">obj1</span> retain]; // retainCount = +2<br />
<br />
// you have one instance of `ObjectA` with a retain count of +2<br />
// both `<span style="color: yellow;">obj1</span>` and `<span style="color: yellow;">obj2</span>` point to the same single instance<br />
}<br />
<br />
-(void) fun3 <br />
{<br />
ObjectA * <span style="color: yellow;">obj1</span> = [[ObjectA alloc] init]; // retainCount of `<span style="color: yellow;">obj1</span>` object = +1<br />
ObjectA * <span style="color: yellow;">obj2</span> = [<span style="color: yellow;">obj1</span> copy]; // retainCount of `<span style="color: yellow;">obj2</span>` object = +1<br />
<br />
// you have two instances of `ObjectA`, each with a retain count of +1<br />
// `<span style="color: yellow;">obj1</span>` points to one instance and `<span style="color: yellow;">obj2</span>` point to the other<br />
}<br />
<br />
-(void) fun4<br />
{<br />
ObjectA * <span style="color: yellow;">obj1</span> = [[ObjectA alloc] init]; // retainCount of `<span style="color: yellow;">obj1</span>` object = +1<br />
ObjectA *<span style="color: yellow;"> obj2</span> = [<span style="color: yellow;">obj1</span> mutableCopy]; // retainCount of `<span style="color: yellow;">obj2</span>` object = +1<br />
<br />
// you have two instances of `ObjectA`, each with a retain count of +1<br />
// `<span style="color: yellow;">obj1</span>` points to one instance<br />
// `<span style="color: yellow;">obj2</span>` points to another instance, which is mutable copy of the `<span style="color: yellow;">obj1</span>` instance<br />
}<br />
<br />
@end<br />
<br /></div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-71555328325422247732013-03-02T05:31:00.002-08:002014-01-13T23:04:21.166-08:00Disable multitasking support in iOS 4 app<div dir="ltr" style="text-align: left;" trbidi="on">
Multitasking support is enabled by default in all iOS 4+ application. There can be situations where you need to disable this support (if you don’t want your app to run in background).You can disable multitasking in iOS 4+ app just by adding a key in your info.plist file.<br />
You just need to add this following key (right click on your info.plist file and open as plain text file) –<br />
<br />
<key> UIApplicationExitsOnSuspend </key> <br />
<true/><br />
<br />
If you are using visual editor to edit info.plist file the just click on “+” button and add ‘UIApplicationExitsOnSuspend’ key and press tab key and select the check mark.<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<br /></div>
</div>
shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0tag:blogger.com,1999:blog-6168946546989498215.post-63682847858435873942013-02-16T03:36:00.001-08:002013-02-16T03:43:11.560-08:00<div dir="ltr" style="text-align: left;" trbidi="on"><br />
nice to help others<br />
<br />
</div>shoeb khanhttp://www.blogger.com/profile/00273483337196178741noreply@blogger.com0