<?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 Missy Allan on Medium]]></title>
        <description><![CDATA[Stories by Missy Allan on Medium]]></description>
        <link>https://medium.com/@missyalienn?source=rss-dcfe6733e810------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*d-kkIL_qr9XnDGnSiGviIQ.png</url>
            <title>Stories by Missy Allan on Medium</title>
            <link>https://medium.com/@missyalienn?source=rss-dcfe6733e810------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:54:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@missyalienn/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[Six Productivity and Wellness Tips for Working From Home]]></title>
            <link>https://medium.com/@missyalienn/how-to-stay-sane-working-from-home-f5feff3aff75?source=rss-dcfe6733e810------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5feff3aff75</guid>
            <category><![CDATA[work-life-balance]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[remote-working]]></category>
            <category><![CDATA[wellness]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Missy Allan]]></dc:creator>
            <pubDate>Fri, 03 Feb 2017 23:43:01 GMT</pubDate>
            <atom:updated>2017-02-04T00:35:52.414Z</atom:updated>
            <content:encoded><![CDATA[<h4>Be your best self and do your best work</h4><h4>01. Create a routine and stick to it</h4><p>Perhaps the most important tip when working from home: create a routine and stick to it. This means: wake up at the same time every day. Eat breakfast. Shower. Pick an outfit for the day. Do your thang! The important thing is that you do it consistently. It can be easy to wake up at whenever-you-want-o’clock when working from home, but try writing out a routine during your working hours and sticking to it. I guarantee you’ll start feeling better and more productive when you write out everything you plan to accomplish for the day and a rough schedule for when you’re going to do it.. Try it!</p><h4>02. Set up a distraction-free work station</h4><p>Working from home can be both challenging and rewarding. One of the key challenges about working from home is time management, and the abundance of distractions waiting to pull you away from your most important work. So how can you avoid the feet-up-on-the-couch, scrolling through Instagram moments when you’re working from home? Set up a work station! First, acknowledge that more distractions exist in your home than at the office or your local coffee shop, and plan accordingly. Second, Set up a clean and clutter-free area like a desk or table and put your phone on airplane mode for at least an hour. Third, adopt this attitude about your newly created work station: It’s for work. Period! When you’re at your work station, you do work. Promise you’ll be more productive with a designated working area than without!</p><h4>03. Stay hydrated and take breaks</h4><p>Another super important thing when you’re working from home, or working at all, is to stay hydrated. Of course, you say. “I know how important it is to drink water and stay hydrated!” Ok, so how many glasses of water have you had today? Be honest. If you’re at 8 or above, kudos! You’re nailing it. But if not, get up and get slurping! Seriously. Water is critical to brain function, creative thinking, and reducing fatigue. Try keeping a water bottle at your work station and take a few sips from it every hour.</p><p>Let’s not forget how important taking breaks are either. Some research even suggest a 5–8 minute break every hour could be the most beneficial for your productivity. If that sounds like a little too much interruption, try 10 minutes every 2 hours. Those bathroom breaks you used to take at the office were helping you more than you may have realized, and now that you’re working from home, you might not be taking enough breaks to get the creative juices flowing. Try walking around your apartment for the duration of one of your favorite songs, 3–5 minutes. Or, if you’re feeling extra brave, get outside and go for a quick trip around the block. Guarantee you’ll be feeling more energized and in the zone when you make it back to your work station!</p><h4>04. Get outside</h4><p>Just like when you were at the office and would take a little break to catch some fresh air, your mind and body need the same care when you’re working from home. While scurrying around your apartment can be helpful, there’s nothing like a good old walk around the block to clear your head. Try walking around the block after lunch — bonus points if you cook it yourself and eat outside (if it’s not too chilly!).</p><h4>05. Explore your most creative time of day</h4><p>Is your mind buzzing with new ideas when you first wake up in the morning? Or do plans come to you right before you’re about to hit the hay? Most of us have certain times of the day when we feel most creative and our ideas flow freely. Instead of forcing yourself to brainstorm when things aren’t flowing, try to pay attention to what time of day you feel most inspired and connected with your work. For me, I am particularly creative in the afternoon. Working from home allows me the flexibility to schedule when I work (pretty amazing!) so I try to remember that and be grateful.</p><p>Pay attention to what jump-starts your creativity and try to recall on it when things aren’t flowing. Not all may feel they have a most creative or productive time of day, but if you’re struggling to get flowing, things like music, dance, stretching, yoga or some other physical activity, and <a href="http://www.mindbodygreen.com/0-17207/5-invigorating-essential-oils-how-to-use-them.html">aromatherapy</a> can help get things going.</p><h4>06. Know when to call it quits</h4><p>Do you ever find yourself in bed or on the couch with your computer at 11:30 PM asking “How did I get here?” We’ve likely all been there. One of the dangers of working from home can be that your work can tend to slide further into your personal time. This is because there are so many distractions at home, and it can be very hard to focus during your designated work time. Start by acknowledging that it’s harder to pull yourself away from work when you’re working from home. Then, similarly to the work routine you created in the first bullet, come up with an after-work agenda for yourself, and stick to it! Yoga, dinner, movies anyone!?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5feff3aff75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intro to Realm: Getting Started with the Realm Mobile Platform]]></title>
            <link>https://medium.com/@missyalienn/intro-to-realm-getting-started-with-the-realm-mobile-platform-e60ddbc24413?source=rss-dcfe6733e810------2</link>
            <guid isPermaLink="false">https://medium.com/p/e60ddbc24413</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[realm]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Missy Allan]]></dc:creator>
            <pubDate>Wed, 18 Jan 2017 19:09:17 GMT</pubDate>
            <atom:updated>2017-01-24T15:47:48.143Z</atom:updated>
            <content:encoded><![CDATA[<p>A beginner’s dive into Realm!</p><h3><strong>What is the Realm Mobile Platform?</strong></h3><p>When Realm was launched in 2014, the goal was to help mobile developers build better apps faster by giving them a robust alternative to SQLite and Core Data.</p><p>The Realm Mobile Platform is a new offering from Realm that integrates Realm’s fully open-source client-side database for iOS and Android with new server-side technology providing realtime synchronization, conflict resolution, and reactive event handling. This new platform makes it easy for developers to create apps with difficult-to-build features like realtime collaboration, messaging, offline-first experiences, and more.</p><p>Realm allows developers to do all of this without having to touch server-side code. The Realm Mobile Database works on all major mobile platforms to provide offline-first functionality &amp; data persistence through an easy-to-use API, and the Realm Object Server provides automatic data sync, simple authentication, access controls, event handling, and more.</p><h3><strong>What is a database?</strong></h3><p>A database is a collection of information that is organized in such a way that it can easily be accessed, managed, and updated. Databases are sometimes classified according to their organizational approach with the most common being the <a href="http://searchsqlserver.techtarget.com/definition/relational-database">relational database</a>.</p><p><strong>Relational databases</strong> like MySQL, PostgreSQL and SQLite3 represent and store data in tables and rows. These databases are based on a branch of algebraic set theory known as relational algebra. Meanwhile, <strong>non-relational databases</strong> like MongoDB represent data in collections of JSON documents.</p><p><strong>So which type of database is Realm you ask?</strong> Well, according to Realm themselves, Realm is the<strong> first database built exclusively to run in phones, tablets, and wearables.</strong> Unlike regular, server-side databases, Realm can be used directly inside iOS apps to store &amp; query data locally on the device, allowing you to build apps that are faster and offline first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*k1H9XbQbzh5VzTBqdtHw7Q.png" /><figcaption>The Realm Mobile Platform</figcaption></figure><h3><strong>Step 1. Getting Started</strong></h3><p>Ok, now that we know a little bit about databases and Realm, let’s get started: The first thing to do is to follow the instructions under <strong>Getting Started </strong>on Realm’s site. Realm’s instructions are pretty straight-forward, but I will also be walking through the setup in this blog post and attempting to provide a little more context for beginners.</p><p><strong>So, first:</strong> Click on your operating system: MacOS or Linux and this will start a download of a zip file of the Real Mobile Platform.</p><h3><strong>Step 2: Starting the Realm Object Server</strong></h3><p>Head over to your <strong>“Downloads”</strong> folder and open the <strong>“realm-mobile-platform” </strong>folder. Then double-click on the <strong>“start-object-server.command”</strong> file. This will open a new terminal window and start the Realm Object Server for you. This means the Realm Object Server will be running locally on your machine.</p><p>Starting the server will automatically open the Realm Dashboard in a new tab of your current browser. If not, please go to this link: <a href="http://localhost:9080/">http://localhost:9080</a>.</p><p>From there, register a new admin user by entering your email and choosing a password. After registering, you can use these credentials to log in to Realm at any time. Realm’s Dashboard will show you the status of the Realm Object Server, current activity, and also allow you to manage users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*0UhDemO-o-I1rWkehMcTkw.png" /><figcaption>The Realm Dashboard after registering a new admin</figcaption></figure><h3><strong>Step 3: Running the Realm Tasks App</strong></h3><p>RealmTasks is a task management app powered by the Realm Mobile Platform. Realm provides this demo app to you so that you can get a feel for how Realm works and interacts with mobile apps.</p><p>To access RealmTasks, open the <strong>“Demo”</strong> folder inside <strong>“realm-mobile-platform”</strong>, then open the <strong>“RealmTasks” </strong>folder.</p><p>When the app launches, you can log in as an existing user or register a new user. Since this is your first time using the app, click<strong> “Register”</strong> and enter a username and password. (It can be anything; this is simply a local demo!)</p><p>Awesome! Now the app is ready to use.</p><p><strong>Some Things to Try with the Realm Tasks App</strong></p><ol><li>Click the “+” button to add tasks</li><li>Swipe left on a task to delete it</li><li>Swipe right on a task to mark it “done”</li><li>Tap, hold and drag to re-order tasks</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*hLNTumwhQHIiGRM_jYXnVA.png" /><figcaption>The Realm Task app, local demo on MacOS.</figcaption></figure><p>These tasks will be added to your local Realm inside the app while being live-synchronized with the Object Server.</p><p>If you previously ran RealmTasks and want to reset its state, close the app, then run this command:</p><pre>rm -rf ~/Library/Containers/io.realm.realmtasks.maco</pre><h3>The Realm Browser</h3><p>The Realm Browser is a built-in browser that allows you to explore and interact with your Realms in real-time on the server.</p><p>Open the macOS app named <strong>“RealmBrowser” </strong>inside the <strong>“realm-mobile-platform”</strong> folder. The app will open a panel with initial options. Click <strong>“Connect to Object Server”.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*9_ObAEJ8L0ZRb99z55DjYA.png" /><figcaption>Click “Connect to Object Server”</figcaption></figure><p>In the <strong>“Connect to Object Server”</strong> dialog box, enter <strong>realm://127.0.0.1:9080</strong> as the server URL.</p><p>In order to connect as admin we will also need an admin access token. In the terminal window running the server, look for a line starting with <strong>Your admin access token is:</strong>. Copy the long token key string, i<strong>ncluding the two trailing equals signs (</strong><strong>==)</strong>. This is the admin access token for your Object Server. Your admin access token is unique to you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yj57n1HlDK_WMquFuNysAQ.png" /><figcaption>Copy the admin access token from your Terminal window.</figcaption></figure><p>A new dialog box will open, listing all the Realms on your server. If you only registered one user, there will be only one Realm. Select it to view the contents.</p><p>If you still have the RealmTasks app open, you can now try editing and reordering your tasks while seeing the changes live in the browser. Changes in the browser are reflected instantly in the app as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*WbhKl7XIcdLvIAvAqNAMfw.png" /><figcaption>Marking tasks as complete in the app, and changes are reflected in real-time in browser.</figcaption></figure><h3>Ok, now what?</h3><p>Now that we’ve set up the Object Server, and tried out the demo app, we’ll try to compile and run a real mobile app. Woohoo! Stay tuned for Part 2: <strong>Building a Sample App with Realm.</strong></p><p>Sources: <a href="https://realm.io/docs/get-started/installation/mac/">https://realm.io/docs/get-started/installation/mac/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e60ddbc24413" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Downloading Image Data from a URL — NASA API — Astronomy Pic of The Day (Swift 3)]]></title>
            <link>https://medium.com/@missyalienn/astronomy-picture-of-the-day-with-nasa-api-swift-3-9b825f44fb6d?source=rss-dcfe6733e810------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b825f44fb6d</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[nasa]]></category>
            <dc:creator><![CDATA[Missy Allan]]></dc:creator>
            <pubDate>Fri, 04 Nov 2016 17:34:30 GMT</pubDate>
            <atom:updated>2016-11-04T18:44:12.549Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s week 6 here for Flatiron School’s iOS 09–16 class, and we recently started learning about APIs — how to make requests and get data back from the internet to use in our own applications. Awesome!</p><p>I arrived at school yesterday morning feeling kinda overwhelmed, still struggling to understand how to work with APIs. I knew we were going to be having assessments with instructors — quizzing our knowledge of the basics of making API calls and parsing JSON data. I wanted to test myself to see if I could do the thing outside the structure and instructions of the labs we’ve been given in class. So I thought hmm.. what am I passionate about? And duh! The answer is space!! So I went to the NASA API and embarked on a mission to retrieve data from it.</p><p>Maybe you like space too, or maybe you’re curious about how to work with APIs in Swift. This post is an attempt to share my thought / code process from my own journey. Happy Coding!</p><h4>1. Apply For An API Key</h4><p>Head over to <a href="https://api.nasa.gov/index.html#getting-started">https://api.nasa.gov/index.html#getting-started</a> and click <strong>“Apply for your API key.” </strong>NASA will then ask for your name, email address, and a little info about how you’ll use the API. I told them the truth: I’m a student, and I’ll be using the API to practice and learn!</p><h4><strong>2. Take it to Postman!</strong></h4><p>Once you have your key, drop the full link into Postman to check what the API returns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*K9ynyIiijzKqXKmHrn8q8w.png" /><figcaption>NASA APOD API in Postman</figcaption></figure><p>Lucky for us, we see it <strong>returns a simple dictionary of type [String : String]</strong>. Wow! How blessed are we!? A well-documented API that returns a dictionary with key: value pairs of the same type? Thanks NASA!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl46Cb241IDoJbSxQ4%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Faishwarya-rai-asian-women-asianwomen-l46Cb241IDoJbSxQ4&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl46Cb241IDoJbSxQ4%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="213" frameborder="0" scrolling="no"><a href="https://medium.com/media/0870258f6d0b1b1d77134e20c185e5db/href">https://medium.com/media/0870258f6d0b1b1d77134e20c185e5db/href</a></iframe><h4>3. Time to Code!</h4><p>First things first, create a new Swift file called “<strong>NASAApiClient” </strong>or whatever you want. This is where you will do the thing: make your API calls and handle the response.</p><p>Next, you’ll need a function to get data from the API. I called mine <strong><em>getDataFromAPI</em></strong><em>.</em> Give the function a completion closure so you can call on it later. My completion closure has an argument of type <strong>(JSON)</strong> aka <strong>[String: String]</strong>, but you could also have a completion closure with no arguments. Your call!</p><pre>class NASAAPIClient {</pre><pre>typealias JSON = [String : String]</pre><pre>static func getDataFromAPI(with completion: @escaping (JSON) -&gt;()) {</pre><h4>4. Set up your <strong>getDataFromAPI</strong> function.</h4><p>Create a URL object from a URL string containing the base URL of the API and your unique API key. The url object is inherently optional, so be sure to use <strong>if let </strong>or <strong>guard let</strong> to unwrap that puppy!</p><pre>let urlString = “https://api.nasa.gov/planetary/apod?\(Secrets.apiKey)&quot;</pre><pre>let url = URL(string: urlString)</pre><pre>guard let unwrappedURL = url else {return}</pre><p>The next thing we’ll need is a <strong>session</strong>. You can read more about those <a href="https://developer.apple.com/reference/foundation/urlsession">here</a>.</p><pre>let urlString = “https://api.nasa.gov/planetary/apod?\(Secrets.apiKey)&quot;</pre><pre>let url = URL(string: urlString)</pre><pre>guard let unwrappedURL = url else {return}</pre><pre>let <strong>session</strong> = URLSession.shared</pre><h4>5. Now comes the fun, the dataTask!</h4><p>dataTasks must be created using the <strong>session</strong> object and require either a URL or a request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*ef6B7e4j4ZXCZzq_b2R3WA.png" /><figcaption>session.dataTask</figcaption></figure><p>Create a task variable that uses the <strong>session.dataTask(with:, completionHandler:)</strong> method. Give it your unwrapped url object and use xCode’s autocomplete to enter variable names for the closure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*PJJkFzzwYOILTGbzeJuzcw.png" /></figure><pre>let task = session.dataTask(with: unwrappedURL) { (data, response, error) in </pre><h4>6. Parse all the JSON.</h4><p>JSON can be obtained from the data sent back from the server. We will be using the data variable to create some <strong>JSON</strong>. <strong>Data</strong> is also an optional value so we must first unwrap the data too.</p><p>For more info on the parsing JSON, see <a href="https://github.com/learn-co-curriculum/swift-internet-review">here</a></p><p>Here’s our completed function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2HCthJQ6gl7xQhpZtp1Fzw.png" /></figure><p>The print statements we added in our <strong>do, try, catch</strong> block indicate that it is working! We are getting data and printing the value for the dictionary’s “explanation” key to the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*FH6kCeclj2_bDdmdKSxc7w.png" /><figcaption>Print statements show we are successfully getting data back from NASA API!</figcaption></figure><p>That’s all fantastic, but what we really want to do is display the picture of the day. I wanna see some cool galaxies!</p><h4><strong>7. Wait, but how do we display the pic of the day from a URL?</strong></h4><p>Heading back to Postman we can see that the value for the key <strong>“url”</strong> in our dictionary is another String — a URL.</p><p>“url”:“<a href="http://apod.nasa.gov/apod/image/1611/PacmanCrawfordNew1024.jpg">http://apod.nasa.gov/apod/image/1611/PacmanCrawfordNew1024.jpg</a>&quot;</p><p>Well… what is an image anyways? Turns out it’s just bits and bytes of data like anything else! Knowing this, we can create a function to get the image data from the URL and create an image object out of it.</p><h4>8. Create a function to get data from the URL and make an Image out of it.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*92ZRSLHO2fPfpbGB_-NE2Q.png" /></figure><p>I am gave my function two arguments, a <strong>urlString</strong>, corresponding to which url we want to use for our image, and a <strong>completion closure</strong> with two arguments, a <strong>Bool</strong> and an <strong>optional UIImage</strong>. To implement this function we follow the same steps as before, but instead of a <strong>dataTask</strong> that gives us a <strong>JSON</strong> object, we want the <strong>dataTask</strong> to create a <strong>UIImage</strong> object from the data (a urlString).</p><p>You may have been wondering why our <strong>downloadImage</strong> function took an argument of type <strong>String</strong> (for urlString) rather than of type <strong>URL</strong>. Well, since NASA’s Astronomy Pic of the Day returns a new URL everyday, there’s no one URL that we can pass into this function. The URL changes everyday. Thus, we must give it an argument of type <strong>String — </strong>equivalent to the value (the url) at the dictionary’s “url” key.</p><p>Here we are calling on our functions from the APIClient so that we can display this data in our View Controller.</p><pre>override func viewDidLoad() {</pre><pre>super.viewDidLoad()</pre><pre>NASAAPIClient.getDataFromAPI { <strong>(data)</strong> in</pre><pre>NASAAPIClient.downloadImage(at: <strong>data[“url”]!</strong>, completion: { (success, image) in</pre><pre>      if success <strong>== </strong>true {</pre><pre>          print(“got image data from URL”)</pre><pre>          DispatchQueue.main.async {</pre><pre>           self.picOfTheDay.image = image<br>           self.dateLabel.text = “\(data[“date”]!)”                  <br>           self.imageTitle.text = “\(data[“title”]!)<br>           self.imageExplanation.text = “\(data[“explanation”]!)”</pre><pre>         }</pre><pre>    } else {</pre><pre>        print (“Error getting image”)</pre><pre>    }</pre><pre> })</pre><pre>}<br>}</pre><p>And VOILA! You got data from a URL and turned into an Image. AWESOME!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*6DmxWxJcG7de8DkSNSSayw.png" /><figcaption>One View Controller displaying data from NASA’s APOD API</figcaption></figure><p>Many thanks to Jim, <a href="https://medium.com/@bensu1013">Ben</a>, and StackOverflow for the helps.</p><p><a href="http://stackoverflow.com/questions/24231680/loading-downloading-image-from-url-on-swift">http://stackoverflow.com/questions/24231680/loading-downloading-image-from-url-on-swift</a></p><p>Feel free to check out the code on github! <a href="https://github.com/missyalienn/NASAPicOfTheDay">https://github.com/missyalienn/NASAPicOfTheDay</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b825f44fb6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Animate That Table View!]]></title>
            <link>https://medium.com/@missyalienn/animate-that-table-view-7fca75649769?source=rss-dcfe6733e810------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fca75649769</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Missy Allan]]></dc:creator>
            <pubDate>Thu, 20 Oct 2016 17:12:49 GMT</pubDate>
            <atom:updated>2017-02-02T03:20:59.285Z</atom:updated>
            <content:encoded><![CDATA[<p>Table views are one of the fundamental views of iOS. They make it easier to present a large volume of information in an easy-to-read (and easy-to-scroll) manner.</p><p>Many of the apps we use today are comprised of TableViews. The Settings app on your iPhone is a TableView. The “Stories” page in Snapchat is a TableView of all your friends and their stories. TableViews are basically everywhere where there’s data.</p><h3>Table View Fundamentals</h3><p>Don’t remember how TableViews work? Let’s do a super quick review:</p><p>Table views are comprised of <strong><em>cells</em></strong>. Each cell represents a single piece of data in a larger data set. You can define how to draw a single cell, and the table view will take care of the work of drawing the many cells in your data set and scrolling them.</p><p>TableViews go hand in hand with data! They are backed by a <strong><em>data source</em>. </strong>The data source provides the pieces of data that will be drawn into each individual cell of the table view. Cool!</p><p>If you use the standard <strong>UITableViewController</strong> created by Apple, the TableView setup will be mostly done for you. For this project, we won’t do that, because there’s no challenge! We’ll do the long way. The long way allows us to practice TableViews and even a little bit of Protocols too.</p><h3><strong>Setup your TableView</strong></h3><p>I won’t go into a ton of detail here, because we’ve all been practicing this.</p><ol><li>Drag a TableView object from Object Library onto your View Controller.</li><li>Add a Cell to Your Table View.</li><li>Give the cell a reuse Identifier “basicCell”</li><li>Add an IBOutlet from your TableView to ViewController.swift so your code “knows” what the TableView is.</li><li>In View Controller.swift, make sure your View Controller adopts and conforms to the necessary protocols for TableViews: <strong>UITableViewDelegate</strong> and <strong>UITableViewDataSource</strong></li><li>Going back to Storyboard: Make sure your ViewController is set to the right Class.</li><li>Head over to Connections Inspector and control-drag the delegate &amp; dataSource over to your View Controller.</li><li>Back in ViewController.swift, implement the necessary methods for TableViews.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-BeKs0MnfZuEQG6qNDKOw.png" /></figure><h3><strong>TableView + Animation = Cool TableView!</strong></h3><p>TableViews are great. But, TableViews with animations are better! Let’s try adding an animation to our TableView. First, create constants for the cells and the TableView’s height.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*WjFZ3oxmsPjzIJlI-03JNg.png" /></figure><p>Next, loop through the cells that are currently visible on the screen and move each of them to the bottom of the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VxaJ_uIADxy-9ukOiA5wg.png" /></figure><p>Next, let’s iterate through the cells that we moved to the bottom of the screen and use an animation to get them back into position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JBK7uUjs8CeLtIwCjcUoHA.png" /></figure><p>Using <strong>springWithDamping, </strong>we can<strong> </strong>create a slightly bouncy effect.</p><p>How does this work?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FqjrkBa13Ee8wM%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Fbounce-qjrkBa13Ee8wM&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FqjrkBa13Ee8wM%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="256" frameborder="0" scrolling="no"><a href="https://medium.com/media/9596e8ce7a25c756486468106fe0f857/href">https://medium.com/media/9596e8ce7a25c756486468106fe0f857/href</a></iframe><p><strong>springWithDamping:</strong> “Performs a view animation using a timing curve corresponding to the motion of a physical spring.” Thanks Apple. That tells us a lot.</p><p>Spring animations work by changing from a start state to an end state, with a slight overshoot and bounce at the end. For example, if you want to animate a view moving from X:0 to X:100, it might move to X:110 before bouncing back to X:80, then X:120 and finally X:100, as if the animation were attached to a spring.</p><p>Spring animations require two values: how “bouncey” the spring should be, and how fast it should start. The first value is specified with usingSpringWithDamping, — higher values here make the bouncing finish faster. The second value is specified with initialSpringVelocity, where higher values give the spring more initial momentum. That’s pretty much it.</p><p>Now we can make TableViews like this bouncey owl. Neat!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FFfdu8Ta2Rsr5K%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Fcheezburger-bouncing-owls-Ffdu8Ta2Rsr5K&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FFfdu8Ta2Rsr5K%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="234" frameborder="0" scrolling="no"><a href="https://medium.com/media/b580782bf411d7da25cd24fdca6c8ea9/href">https://medium.com/media/b580782bf411d7da25cd24fdca6c8ea9/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fca75649769" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Walk Through HealthKit]]></title>
            <link>https://medium.com/@missyalienn/a-walk-through-healthkit-10434d33ff87?source=rss-dcfe6733e810------2</link>
            <guid isPermaLink="false">https://medium.com/p/10434d33ff87</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Missy Allan]]></dc:creator>
            <pubDate>Thu, 06 Oct 2016 00:16:41 GMT</pubDate>
            <atom:updated>2016-10-06T17:40:08.370Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is HealthKit?</h3><p>HealthKit is an SDK (Software Development Kit) created by Apple for iOS and watchOS. HealthKit was released along with the Health App at WWDC 2014 (Apple’s annual Worldwide Developers Conference). Apple describes HealthKit as a <strong>“single place where apps can store, share, and read health-related data.”</strong> HealthKit allows apps that provide health and fitness services to share their data with the (Apple) Health App and with each other. A user’s health information is stored in a centralized, secure location and the user can decide which data to share.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*2Bd5DzfOyvFkeMdDUPwQLQ.png" /><figcaption>HealthKit — photo by Apple</figcaption></figure><p>HealthKit saves data in a globally accessible database. This means that any app can write and read to this database (given user permission of course). The user interacts with its database via the Health app. HealthKit can transform your app into a valuable health data source that uses shared data to bring more powerful health and fitness solutions. Pretty cool!</p><h3><strong>What are we building?</strong></h3><p>We’re going to build a simple step-tracker app that will request authorization to use HealthKit, and then read and write HealthKit data. In this post, however we’ll focus mainly on requesting authorization to use HealthKit.</p><p>Cool! Time to code!</p><p><strong>Step 1: Enable HealthKit</strong></p><p>The first thing we have to do is <strong>enable</strong> HealthKit in our application. We can do this by clicking on our main project in the Project Navigator (left sidebar, top most file). Then, on the main view select the <em>Capabilities</em> tab. Scroll down and toggle HealthKit <strong>“ON.” </strong>Very simple<strong>!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qqG6aI2tsrHATdsnWwx1Bg.png" /></figure><p><strong>Step 2: Create a class called </strong>called <strong>HealthKitManager.</strong></p><p>Classes allow us to encapsulate several pieces of data into one <strong><em>object</em></strong>, which we can refer to using <strong><em>constants and variables</em></strong>. Classes also implement behavior<em> </em>in the form of <strong><em>methods</em></strong> which allow us to interact with <strong><em>instances</em> </strong>of the class. Classes also provide a way for us to create our own type.</p><p><strong>HealthKitManager.swift</strong> is where all of our HealthKit work will take place. It will hold our important variables and methods that we need to get things done. It will let us access an instance of<strong> HKHealthStore()</strong> which is explained more below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJ5tsOojtkMDBUlVgPEHhw.png" /></figure><p><strong>Step 3: Build out HealthKitManager class.</strong></p><p>We will need two main things for now:</p><ol><li><strong>A constant</strong> to access an instance of <strong>HKHealthStore</strong>. HKHealthStore is the place where all of the user’s health data is stored. You can think of it as a global database. We need an instance of it and a way to refer to it in our code. So we’re going to create a constant called called <em>healthStor</em>e and set it equal to HKHealthStore()</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZqVYjyZfkhOsaiOoOi5O_w.png" /></figure><p>Now that we’ve created an instance of<strong> HKHealthStore</strong>, the next step is to request authorization to use it. So what does this mean?</p><p>Setting up the HealthKit framework does three main things: enables the HealthKit capabilities, verifies that HealthKit is available on the device, and requests permission to read and write data.</p><p><strong>2. We will create a method called authorizeHealthKit </strong>to do the last two things (verify HealthKit is enabled on the device and request permission to read and write data). This method returns a Bool because there are two possible outcomes: authorized (true) or not authorized (false).</p><p>Within this method, we start by creating a local variable called <em>isEnabled</em> and set it equal to true. We will default to being authorized. In the second line, we must make sure we have access to HealthKit on our particular device by calling the .<strong>isHealthDataAvailable</strong> method. This is a built in HealthKit method. HealthKit is not available on some devices, like iPad for example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1HYu6eukrgRNKh20d0g1g.png" /></figure><p>Since the user is the master of their data, and controls which metrics you can track, we must request access for each type of object we want to read or write to the healthStore. For this project, we are going to request access to stepCount data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mz7vyCa3_3c0f8f-AFJ49g.png" /></figure><p>Let’s briefly explain some of the new types we are seeing in that last line.</p><p><strong>HKQuantity</strong> is a standardized way to talk about an amount of a specific unit (200 lbs or 5000 steps for example) in HealthKit. HealthKit uses quantity objects to store numerical data.</p><blockquote>From Apple: “Quantities store a value for a given unit. For example, if you can create a length property in feet, you can then request the value in meters. The quantity object automatically converts its value to the requested units, as needed.”</blockquote><p>Another important thing to note: Quantities are immutable objects: Their values are set when the object is first created and cannot change.</p><p><strong>HKQuantityType</strong> helps us specify <strong>what exactly this quantity is referring to.</strong></p><p>From Apple docs:</p><blockquote>“The <strong>HKQuantityType</strong> class is a concrete subclass of the<strong> </strong><a href="https://developer.apple.com/reference/healthkit/hkobjecttype"><strong>HKObjectType</strong></a><strong> </strong>class. HealthKit uses quantity types to create samples that store a numerical value. Use quantity type instances to create quantity samples that you can save in the HealthKit store.”</blockquote><p>So since we want to get get the user’s step data our code can look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sLvtq68pRVT1cJPC-LaWlQ.png" /><figcaption>Requesting StepCount data</figcaption></figure><p>Lastly, we will perform the actual <strong>request to read/write step data</strong> from our instance of HKHealthStore.</p><p>I first tried this code:</p><pre>healthStore.requestAuthorizationToShareTypes(nil, readTypes: steps) { (success, error) -&gt; Void in<br>      isEnabled = success<br>    }<br>  }<br>  else<br>  {<br>    isEnabled = false<br>  }<br><br>  return isEnabled<br>}</pre><p>But I got this error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*7ZmaFEVW79dm13lYmz6tXQ.png" /></figure><p>It is basically telling me that the type I have declared the stepCount data to be is not convertible to the type that the authorization method takes as an argument. Xcode came to my rescue and suggested a fix, and I decided to take Xcode up on that fix. Luckily, it worked! Here is the same code after taking Xcode’s suggestion:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0MRFYAqxt2HIkWWRQqstDw.png" /></figure><p>But how did Xcode fix my method? By using a Swift operator called <strong>as! </strong>Here is some documentation on <strong>as!</strong></p><p><strong>The as! Operator</strong></p><p>“This operator refers to <em>Type casting </em>which is<em> </em>is a way to check the type of an instance, or to treat that instance as a different superclass or subclass from somewhere else in its own class hierarchy.</p><p><em>Type casting</em> in Swift is implemented with the <strong>is</strong> and <strong>as</strong> operators. These two operators provide a simple and expressive way to check the type of a value or cast a value to a different type.”</p><p>So basically what we did with as! is forced downcast the NSSet class to the Set&lt;HKObjectType&gt; subclass. And we’re in business!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcc9kTXXfg_DysqhGSK7KA.png" /></figure><p>We have our completed <strong>authorizeHealthKit</strong> method. Pat ourselves on the back! We just set up the HealthKit framework for our app! Essentially what we’ve done here is ask the user for permission to both read and write their <strong>HKQuantityType</strong> (stepCount) data. Now if the user was to run our app, they would see this screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*ugt0zZynSAZF_wWuZ0Y7_Q.png" /><figcaption>image via NatashaTheRobot</figcaption></figure><p>In the next post, we will build out a method to actually get the recentStep data. Thanks!</p><p>For sources and more info check out these posts:</p><ul><li><a href="https://www.natashatherobot.com/healthkit-getting-fitness-data/">HealthKit: Getting Fitness Data</a></li><li><a href="https://www.raywenderlich.com/86336/ios-8-healthkit-swift-getting-started">HealthKit Tutorial with Swift: Getting Started</a></li><li><a href="https://swift.unicorn.tv/articles/step-counter-in-healthkit">Swift Programming Blog - Step Counter in HealthKit</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10434d33ff87" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>