<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dennis Vera on Medium]]></title>
        <description><![CDATA[Stories by Dennis Vera on Medium]]></description>
        <link>https://medium.com/@dennisvera.z?source=rss-3229b2d7a3c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c8KOlgnSKDBN9h8M4yOWsg.png</url>
            <title>Stories by Dennis Vera on Medium</title>
            <link>https://medium.com/@dennisvera.z?source=rss-3229b2d7a3c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:36:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dennisvera.z/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Software Architecture: MVC Design Pattern]]></title>
            <link>https://medium.com/@dennisvera.z/software-architecture-mvc-design-pattern-ceae5d5083d7?source=rss-3229b2d7a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ceae5d5083d7</guid>
            <category><![CDATA[mvc]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Dennis Vera]]></dc:creator>
            <pubDate>Wed, 21 Dec 2016 18:13:27 GMT</pubDate>
            <atom:updated>2016-12-21T18:13:27.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Yq2zh4oM3fWrIOvPLadxQw.jpeg" /></figure><blockquote>Software architecture is about making fundamental structural choices which are costly to change once implemented.</blockquote><p>Every software development project goes through a number of phases: concept, design, development, testing and more. It has become evident to me as a junior developer that before any coding begins, it is crucial to thoroughly plan out the architectural foundation of the app to ensure your app is modular, stable, and scalable from the start. Architectural designs help identify potential problems early enough in the project to allow the opportunity to make changes before construction begins. Effective architecture patterns improve code readability because they require considering issues that may not become visible until later on.</p><p><strong>What are architecture design patterns?</strong></p><p>Design patterns are reusable solutions to common problems in software design. They are templates designed to help us write code that is easy to understand, easy to test, and easy to reuse. Design patterns help create loosely coupled code so that its components can be changed or replaced easily in your code later on.</p><p>Structuring your applications with design patterns really pays off down the road. Developers know all too well that our apps go through changes: you may want to add new features, there are bugs that you may need to fix, your employer might ask you to quickly change the color scheme on a view controller, or you may need to update your code to remain compatible with new releases of iOS software or new devices. Architectural design patterns are your guideline to making your applications resilient to these changes.</p><p>Now that we’ve answered the “<em>Why?</em>” let us look into “<em>How?</em>”</p><p><strong>iOS Design Patterns:</strong></p><p>The most common design patterns for iOS development are: <strong>MVC</strong>, <strong>MPV</strong>, <strong>MVVN,</strong> and <strong>Viper</strong>. I will only cover MVC and MVVN as these are the design patterns I am most interested in at this time. In this blog, I will specifically focus on MVC with a follow up blog on MVVN next.</p><p><strong>What is MVC?</strong></p><p>Model View Controller (MVC) was invented by Trygve Reenskaug in 1979. It is the most common object-oriented design pattern for iOS development. MVC allows for a very clear separation of the application’s data — logic, the view, and the controller. MVC classifies objects according to their general role and encourages clean separation of code based on each role. Each object falls into one of these groups:<br> <br>The<strong> Model </strong>is responsible for data and logic: things like persistence, model objects, parsers and networking code live here.</p><p>The <strong>View </strong>is responsible for the objects that are in charge of the visual representation of the Model and the controls the user can interact with; think of anything starting with the “UI” prefix.</p><p>The<strong> Controller </strong>acts as an intermediary between the application’s view objects and its model objects. The controller orchestrates view events and model changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*lLHA453XLDC9DFWDNsgdBg.png" /></figure><p>Now that we see how MVC manages communication between these 3 camps, our job is to keep a clear separation of code based on the role each object has. Keeping true to MVC design patterns requires constant attention to where your objects live in order to avoid potential pitfalls. Here are a few guidelines to keep in mind:</p><ul><li>The <strong><em>controller</em></strong> can talk to and knows everything about the model. It is the controller’s job to get what it needs from the model to display to the user.</li><li>The <strong><em>controller</em></strong> can also talk directly to the views via Outlets that we create in the controller.</li><li>The <strong><em>views</em></strong> are just <em>minions</em> of the controller — keep the views simple!</li><li>The <strong><em>model</em></strong> and the <strong>v<em>iews</em></strong> should <strong><em>never ever</em> </strong>speak to each other.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*p8hbtF7dhudZEWI9B2vryA.png" /><figcaption>Stanford— Paul Hegarty lecture on MVC</figcaption></figure><p><strong>MVC Drawbacks:</strong></p><p>There are no silver bullets when it comes to design patterns. In MVC the view and the controller are closely coupled. A iOS view-controller class will usually contain both UI logic <em>and</em> data logic which makes the modification of one affect the other— creating a sort of “M/VC” variation of MVC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*6gl0QP20_gJjiOBIIGEQ4g.jpeg" /></figure><p>As view controller classes implement increasingly complex UI requirements like networking and parsing, the amount of data-logic code also tends to grow within the same view controller class. This typically results in large, unwieldy view controller classes that are difficult to refactor, test, and read. For these reasons MVC has also become known as the <strong>Massive View Controller.</strong></p><p><strong>Conclusion:</strong></p><p>A solid architectural design pattern will define the overall quality of your code. It will determine how flexible, clear and reliable your code is. A solid architectural pattern will lead you to ask the right questions about your objects from the beginning.</p><p>A building with a shaky foundation eventually always topples!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ceae5d5083d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift 3: Multithreading With Grand Central Dispatch]]></title>
            <link>https://medium.com/@dennisvera.z/swift-3-multitasking-with-grand-central-dispatch-gcd-d0f7e02046e3?source=rss-3229b2d7a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0f7e02046e3</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Dennis Vera]]></dc:creator>
            <pubDate>Sun, 04 Dec 2016 21:43:03 GMT</pubDate>
            <atom:updated>2016-12-05T16:40:14.444Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w6H0HcSHytq_I-p27XKiSQ.jpeg" /></figure><p>Since the arrival of Swift 3.0, the first major release of Swift since it was open-sourced, developers are <em>swiftly</em> catching up to all of the major improvements and refinements to the core language and Standard Library. One of the big and welcoming change has been to <strong><em>Grand Central Dispatch</em></strong> <strong>(GCD)</strong>. GCD is one of the most used technologies on all Apple platforms when it comes to performance, concurrency, parallelization and threading.</p><p>The most frequent problem that we solve with GCD is the ability to run tasks on the background thread in order to not block the UI, which runs in the main thread. A common task in app development is downloading images from a server, this task can take <strong><em>x</em></strong> time to complete, so if you are running this task in the main thread you will block the UI and the user will no longer be able to operate the app. Creating an unpleasant user experience, and possibly crashing the app. We solve this problem with GCD by assigning tasks to the background thread. GCD takes advantage of the multitasking capabilities of the CPU, by assigning tasks to different threads or different queues other than the main one.</p><p>Besides GCD, Apple also provides <em>NSOperationQueue</em> frameworks for writing concurrent code. Both are designed to encapsulate units of work and dispatch them for execution. Understanding the benefits that each provide will help you decide which to implement. In this post I will mainly focus on GCD.</p><p>Check out this excellent blog that explains the differences and benefits of both GCD and NSOperation.</p><p><a href="https://cocoacasts.com/choosing-between-nsoperation-and-grand-central-dispatch/">Choosing Between NSOperation and Grand Central Dispatch - Cocoacasts</a></p><p>Swift 3 changes to GCD has made it easier for developers, certainly for new developers like myself to recall the code and apply in projects. Prior to Swift 3 release GCD syntax, coding style was quite close to low level C, and it was obviously different than any other coding style in Swift. The new GCD API revolves mostly around the<strong><em> DispatchQueue</em></strong>. This class enables creating and modifying queues, dispatching code <em>synchronously</em> or <em>asynchronously</em> and much more.</p><p>A D<em>ispatchQueue</em> can be either <em>serial</em>, so that work items are executed one at a time, or it can be <em>concurrent</em>, so that work items are dequeued in order, but run all at once and can finish in any order. Both serial and concurrent queues process work items in <em>first in, first-out</em> (FIFO) order.</p><p><strong><em>Synchronous</em></strong> essentially means<strong> “in order.”</strong> Basically, when you do a synchronous operation, everything that comes later has to wait for the operation to finish before they can start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wlCXV3Ap3qnIhJaceNxTKA.png" /></figure><p><strong><em>Asynchronous</em></strong> more or less means <strong>“not in order.”</strong> When you do something asynchronously, the following code can immediately run and the asynchronous operation will be run…sometime. It might be run in parallel with the rest of the code on another thread. It might simply be scheduled for some other time on the same thread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*X7k0aTymfRe3gnW982Wslw.png" /></figure><p>GCD dispatch makes it exceptionally easy to perform asynchronous operations on a background thread. Lets look at the block of code below from a movie app that I’m currently working on. First I make an API call to the OMDB (a movie database) server, if the request is successful I parse the JSON and update the UI inside the <strong><em>DispatchQueue.main.async {…} </em></strong>block. Any code inside <em>DispatchQueue </em>block, like uploading a movie poster image will run on a separate thread and will update the UI when completed. While this task is running the user can still operate the app unblocked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M6UaZh5yNKe793PPjptjhg.png" /></figure><p>There are many more tasks that you can accomplish with GCD, take a look at Apple’s API Reference on Dispatch to learn about all of the tasks you can manage with the new and improved GCD.</p><p><a href="https://developer.apple.com/reference/dispatch">Dispatch</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0f7e02046e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift — Dynamic UILabel Text]]></title>
            <link>https://medium.com/@dennisvera.z/swift-dynamic-uilabel-text-d5b377d96991?source=rss-3229b2d7a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5b377d96991</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Dennis Vera]]></dc:creator>
            <pubDate>Wed, 21 Sep 2016 03:21:07 GMT</pubDate>
            <atom:updated>2017-01-09T15:20:47.776Z</atom:updated>
            <content:encoded><![CDATA[<p>While working on a project making multiple API calls and parsing text from the API response I ran into a problem with the unpredictable amount of text i was receiving. Some of the text easily fit in 2–3 lines and other text required 6–7 lines or more to properly fit. I kept adjusting my text labels using <em>Line Breaks</em> (word wrap) and changing the <em>Line Count</em> to account for the lines of text I received back from the API. I quickly got the awful feeling that is not very smart, there’s got to be a better way. And of course there is, as always, your code should be dynamic, it should be able to adjust to the incoming data. The same rule applies here, my text label should be adaptive to a single or multiline.</p><p>The Solution: lets set up a simple project for practice. Take a Single View application and in Storyboard Add a UILabel and a UIButton. Define constraints to UILabel as below snapshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/0*AUp52FVyYs-pTdTX.png" /></figure><p>Set the Label properties as below image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*YdemczawH9HP417O.png" /></figure><p>Add the constraints to the UIButton. Make sure that vertical spacing of 100 is between UILabel and UIButton</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/0*pGazO0_2RDCBb-Mc.png" /></figure><p>Now set the priority of the trailing constraint of UILabel as 749</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/0*SxWLhw3pTaWsVXLh.png" /></figure><p>Now set the Horizontal Content Hugging and Horizontal Content Compression properties of UILabel as 750 and 748</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6hn5wgzT53dK-qsT.png" /></figure><p>Below is my controller class. You have to connect UILabel property and Button action from storyboard to viewcontroller class.</p><pre>import UIKit<br><br>class ViewController: UIViewController {<br><br>@IBOutlet weak var textLabel: UILabel!<br>var count = 0<br>let items = [&quot;jackson is not any more in this world&quot;, &quot;Jonny jonny yes papa eating sugar no papa&quot;, &quot;Ab&quot;, &quot;What you do is what will happen to you despite of all measures taken to reverse the phenonmenon of the nature&quot;]<br><br><br>@IBAction func updateLabelText(sender: UIButton) {<br>    if count &gt; 3 {<br>        count = 0<br>    }<br>    textLabel.text = items[count]<br>    count = count + 1<br>}<br><br>override func viewDidLoad() {<br>    super.viewDidLoad()<br>    // Do any additional setup after loading the view, typically from a nib.<br>    //self.textLabel.sizeToFit()<br>    //self.textLabel.preferredMaxLayoutWidth = 500<br>}<br><br>override func didReceiveMemoryWarning() {<br>    super.didReceiveMemoryWarning()<br>    // Dispose of any resources that can be recreated.<br>}<br><br><br>}</pre><p>Thats it. This will automatically resize the UILabel based on its content and also you can see the UIButton is also adjusted accordingly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5b377d96991" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3-D Touch: Quick Actions]]></title>
            <link>https://medium.com/@dennisvera.z/3-d-touch-quick-actions-71af3ae336ce?source=rss-3229b2d7a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/71af3ae336ce</guid>
            <category><![CDATA[3d-touch]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Dennis Vera]]></dc:creator>
            <pubDate>Tue, 06 Sep 2016 18:22:03 GMT</pubDate>
            <atom:updated>2016-09-21T02:06:21.261Z</atom:updated>
            <content:encoded><![CDATA[<p>As a new student of iOS Development i now find myself examining every application I interact with; I think about the blocks of code behind each app function. With my new heightened curiosity for the mechanics I recently noticed the subtle, yet powerful, feature that Apple introduced with the release of the iPhone 6s and 6s Plus: 3D Touch, a hard-press gesture. 3D Touch provides an entirely new way to interact with our phones.</p><p>3D Touch isn’t completely unfamiliar to us as we are all used to Force Touch on MacBook, MacBook Pro, and Magic Trackpad. Obviously there is a difference! 3D Touch is more sensitive in the way that Force Touch can only detect hard presses, whereas 3D Touch can distinguish multiple levels of touches based on how firmly you press. Besides the level of press sensitivity 3D Touch offers some great features like Peek and Pop, and Quick Action and more. Here is a descriptive list of what can be accomplish with 3D Touch:</p><p><strong>Home Screen Interaction <br></strong>On the Home screen, pressing the icon of an app that supports 3D Touch displays an action view. This view lets you quickly perform common app-specific tasks and see interesting information. Calendar, for example, provides a shortcut for creating an event. It also shows the next event on your schedule.</p><p><strong>Quick Actions<br></strong>Quick Actions let users do the things they do most often, faster and in fewer steps. Many of these actions can even be done with a single press, right from the Home screen.</p><p><strong>Peek and Pop<br></strong>A peek lets people use 3D Touch to preview an item, such as a page, link, or file, in a view that appears temporarily above the current context. To peek at an item that supports this functionality, apply a little pressure to the item with your finger. Simply lift your finger to exit the peek. To open the item and see more detail, press a little harder until the item pops and fills the screen. In some peek views, you can swipe up to reveal related action buttons. For example, while peeking at a link in Safari, you can swipe up to reveal buttons for opening the link in the background, adding the link to your reading list, and copying the link.</p><p><strong>Use peeking to provide live, content-rich previews.</strong> Ideally, peeking gives enough information about an item to augment the current task, or helps you decide whether to fully engage the item. For example, preview a link in a Mail message before deciding to open it in Safari or share it with friends. Peeking is often used in tables to view detailed row information before the row is selected.</p><p><strong>Live Photos<br></strong>Apps can incorporate pressure into the photo viewing experience by supporting Live Photos. Live Photos come to life when you press them, using movement and sound to show the moments just before and after the photo was taken.</p><blockquote>“As an app user, I’m always impressed when new technology works so smoothly that you hardly notice the new advances, it’s intuitive; 3D Touch has this sensitivity.”</blockquote><p>This tutorial mainly focuses on the home icon <em>Quick Actions</em> menu and how to add separate icons for each action. Making separate Quick Action icons gives the user visual guidance on what each action accomplishes. Lets make a dummy app and a few Quick Action icons to the dummy app. Our home icon should look like this after we set it up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*ftDBHQixnzjhxRjOWaChPQ.png" /></figure><p>First lest define your Quick Actions in your app’s Info.plist file create a UIApplicationShortcutItems array. This is where we define what the actions are, the title, subtitle, and short cut keys for each. Note that you can only have a max of 4 quick actions off the icon in your app.</p><p><strong>UIApplicationShortcutItemType</strong> — A required string delivered to your app when the user invokes the corresponding quick action.<br><strong>UIApplicationShortcutItemTitle</strong> — A required string displayed to the user on the Home screen as the name of the quick action.<br><strong>UIApplicationShortcutItemSubtitle</strong> — An optional string that is displayed to the user on the Home screen, immediately below the corresponding title string.<br><strong>UIApplicationShortcutItemIconType</strong> — An optional string specifying the type of an icon from the system-provided library.<br>You can find a full list of the icons Apple has in their asset library here:<br><a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationShortcutIcon_Class/index.html#//apple_ref/c/tdef/UIApplicationShortcutIconType">https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationShortcutIcon_Class/index.html#//apple_ref/c/tdef/UIApplicationShortcutIconType</a><br><strong>UIApplicationShortcutItemIconFile</strong> — An optional string specifying an icon image to use from the app’s bundle, or the name of an image in an asset catalog.<br><strong>UIApplicationShortcutItemUserInfo</strong> — An optional, app-defined dictionary. One use for this dictionary is to provide app version information.</p><p>Here is the application Info.plist that includes 3 Quick Actions: Take Photo, Video, and Record Slo-Mo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*uktvXCLTmxyaahExr42GXA.png" /></figure><p>To demonstrate that each action works i made each action to open the app with a different color scheme, and yes! the icons are misleading since this is not a photo / video app but something much more simpler. My intentions is to simply showcase the power of the Quick Action feature and i think the apples photo app demonstrates that well. I will be including this feature in a real project and will share how that works. For now, here is this simple approach that handles 3 different background color scheme with Quick Actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sTIW_g_c2TdPzz-7XnHf9w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71af3ae336ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parsing JSON in SWIFT]]></title>
            <link>https://medium.com/@dennisvera.z/parsing-json-in-swift-132ae800e76e?source=rss-3229b2d7a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/132ae800e76e</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Dennis Vera]]></dc:creator>
            <pubDate>Thu, 14 Jul 2016 12:21:53 GMT</pubDate>
            <atom:updated>2016-07-14T18:02:58.086Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, I am going to show you how to Parse JSON in Swift. But first we need to briefly talk about <strong>Application Program Interface</strong> (API). API is code that allows two software programs to communicate with each other. The API defines the correct way for a developer to write a program that requests services from a Backend System (database).</p><p>Here is a simple analogy to help you think about what is an API: think of API as the waiter in your favorite restaurant, you give the waiter your order, a few minutes later he returns with your spicy shrimp taco. The waiter is the messenger from that connects you to the kitchen, like an API. You request data from an API and in return you get the data that is available at that location.</p><p>To achieve this exchange in code you need a safe way to capture the data, and that data will be represented in a JSON file, this is the industry preferred format. There are also XML files that can achieve this but if you compare the syntax of an XML file to a JSON file you will quickly see why JSON is preferred.</p><blockquote><strong>What is JSON? Why is JSON the preferred data format for data transfers?</strong></blockquote><p><strong>JavaScript Object Notation </strong>(JSON) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of many languages. These properties make JSON an ideal data-interchange language.</p><p>It’s now time to parse some JSON, which means to process it and examine its contents. This isn’t easy in Swift, so a number of helper libraries have appeared that do a lot of the heavy lifting for us. We’re going to use one of them now: download the files for this project from <a href="https://github.com/twostraws/HackingWithSwift">GitHub</a> then look for a file called SwiftyJSON.swift. Add that your project.</p><p>SwiftyJSON lets us read through JSON in an extremely intuitive way: you can effectively treat almost everything as a dictionary, so if you know there’s a value called “metadata” that contains another value called “name”, which in turns contains another value called “dog1”, you can use json[“metadata”][“dog1”][“name”][“breed”] to get the data, then ask for it as a Swift value by using the string property.</p><blockquote><strong>Parsing a JSON file with SwiftyJSON:</strong></blockquote><ol><li>Install SwiftyJSON in your project.</li><li>Create a UITableViewController; we are going to print the data out on a table view controller.</li><li>Create a JSON file (see below) below with the exact data.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*EL2b5VEhJHNZafbP4dmHbw.png" /><figcaption>JSON File</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y6xovT70HTL681tFiTavqA.png" /><figcaption>Parsing JSON file implemantation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*gL6nWFDlLmLkW8QSpz0pbg.png" /><figcaption>Simulator print out with the JSON data</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=132ae800e76e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Meaning of SELF in Objective-C]]></title>
            <link>https://medium.com/@dennisvera.z/the-meaning-of-self-in-objective-c-4d6ae0b8f86c?source=rss-3229b2d7a3c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d6ae0b8f86c</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[objective-c]]></category>
            <dc:creator><![CDATA[Dennis Vera]]></dc:creator>
            <pubDate>Wed, 29 Jun 2016 04:41:28 GMT</pubDate>
            <atom:updated>2016-06-30T12:24:11.301Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Objects both “do things” <em>and</em> “represent things; and they have both <em>internal</em> state that they use in managing their behavior and <em>external</em> state they expose to the world.</blockquote><p>When learning <em>Objective-C</em> some concepts will make sense rather quickly and other concepts will linger unresolved and weigh you down for a while. One thing I’ve learned in the first 4-weeks of the iOS Development Immersive program at Flatiron school is that these concepts cannot go unresolved, you can’t go passed or around them as they are used again and again, they will continue to trip you.</p><p><em>S</em>elf was such a concept for me, i struggled with it for longer than i want to admit, a few times i thought i had finally understood it to then find myself faced with another aspect of <em>self</em> that would trip me again.</p><p>Lets define the keyword <em>self </em>by using it in code<em>.</em> When implementing your class you will likely create a few public instance methods along with lots of other instance methods on which they rely. The instance methods within this class will be calling each other constantly. They do this by sending messages to <em>self</em>.</p><p>The self keyword refers to the instance calling the method . In addition to accessing properties, this can be used to call other methods defined on the same class (e.g., [self anotherMethod]). Here is a simple example that would return the string “Goodnight, mother!” every time you call the sayGoodnightToMother<em> </em>instance<em> </em>method using<em> self:</em></p><pre>@implementation MyClass<br><br>- (NSString *) greeting {<br>    <br>    return @&quot;Goodnight, mother!&quot;;<br>}</pre><pre>- (NSString *) sayGoodnightToMother {<br>    <br>    return [self greeting];<br>}</pre><pre>@end</pre><p>The example above seems straightforward enough, and it is; when the sayGoodnightToMother message is sent to a MyClass instance, the sayGoodnightToMother method runs. It sends the greeting message to <em>self</em>. As a result, the greeting instance method is called; and returns the greeting string.</p><p>Lets take it a step further, lets create a custom class with two properties and two methods and access this class from another class, the “ViewController” class, using the dot.notation syntax. First let’s create the custom class with the methods:</p><pre>//  MYDogClass.h<br>//  DogClass</pre><pre>#import &lt;Foundation/Foundation.h&gt;<br><br>@interface MYDogClass : NSObject<br><br>@property (strong, nonatomic) NSString *name;<br>@property (strong, nonatomic) NSString *breed;<br><br>- (void)bark;<br>- (void)changeBreedToWerewolf;<br><br><br>@end</pre><pre>--------------------------------------------------------------------</pre><pre>//  MYDogClass.m<br>//  DogClass<br><br>#import &quot;MYDogClass.h&quot;<br><br>@implementation MYDogClass<br><br>- (void)bark {<br>    <br>    NSLog(@&quot;Woof Woof!&quot;);<br>}<br>- (void)changeBreedToWerewolf {<br>    <br>    self.breed = @&quot;Werewolf&quot;;<br>}<br><br>@end</pre><p>On the “ViewController” class we first need to import the custom class to gain access, then we will make some changes to the properties in the viewDidLoad method and print them out to the console and verify the changes occurred:</p><pre>//  ViewController.m<br>//  DogClass</pre><pre>#import &quot;ViewController.h&quot;<br>#import &quot;MYDogClass.h&quot;<br><br>@interface ViewController ()<br><br>@end<br><br>@implementation ViewController<br><br>- (void)viewDidLoad {<br>    [super viewDidLoad];<br>    <br>    MYDogClass *myDog = [[MYDogClass alloc] init];<br>    <br>    myDog.name = @&quot;Peanut&quot;;<br>    NSLog(@&quot;Dog Name: %@&quot;, myDog.name);<br><br>    myDog.breed = @&quot;Bouvier des Flandres&quot;;<br>    NSLog(@&quot;Dog Name: %@ Breed: %@&quot;, myDog.name, myDog.breed);<br>    <br>    [myDog changeBreedToWerewolf];<br>    NSLog(@&quot;Dog Name: %@ Breed: %@&quot;, myDog.name, myDog.breed);<br>    <br>    myDog.breed = @&quot;Toy Poodle&quot;;<br>    NSLog(@&quot;Dog Name: %@ Breed: %@&quot;, myDog.name, myDog.breed); <br>}<br><br>@end</pre><pre>CONSOLE PRINT:</pre><pre>Dog Name: Peanut<br>Dog Name: Peanut Breed: Bouvier des Flandres<br>Dog Name: Peanut Breed: Werewolf<br>Dog Name: Peanut Breed: Toy Poodle</pre><p>As you can see on the console print-out we have set the breed property to 3 different values using the dot notation syntax. So, what’s happening in this code? We first created an instance variable (ivar) of the MYDogClass to call and set the properties from that class. we then used self with the dot.notaion and [ ] format to set new values to the properties. The console print out shows the result of all the changes as we set them.</p><p>Here are a few sources that helped me further understand the concept of <em>self</em>:</p><ul><li><a href="http://useyourloaf.com/blog/understanding-your-objective-c-self/">Understanding your (Objective-C) self</a></li><li><a href="http://eschatologist.net/blog/?p=160">When to use properties &amp; dot notation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d6ae0b8f86c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>