<?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 Harry Summers on Medium]]></title>
        <description><![CDATA[Stories by Harry Summers on Medium]]></description>
        <link>https://medium.com/@hsummers96?source=rss-26d84c484230------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4sRMLlwFxrJoxn2KCOSkEw@2x.jpeg</url>
            <title>Stories by Harry Summers on Medium</title>
            <link>https://medium.com/@hsummers96?source=rss-26d84c484230------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 16:14:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hsummers96/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[Summer Day 18 — Bug Fixes, App Icon, and Crashlytics]]></title>
            <link>https://medium.com/@hsummers96/summer-day-18-bug-fixes-app-icon-and-crashlytics-799f3f264afc?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/799f3f264afc</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Sat, 19 May 2018 19:45:25 GMT</pubDate>
            <atom:updated>2018-05-19T19:45:25.188Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-xNv9y49lMdXBWc1Sqs1Q.jpeg" /></figure><p>The first thing I did today was fix the bugs pending in the app. One of the bugs was that the app was not identifying something was in the clipboard during the first app load. It turns out that the window’s root view controller was not the active window since I have pushed other View Controllers onto the stack. So I had to write a function that would get the window’s active view controller. This is the gist of that function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/933dd6db4fdc079d994794e69efb93f2/href">https://medium.com/media/933dd6db4fdc079d994794e69efb93f2/href</a></iframe><p>The idea is that a view controller will have a nil presentedViewController attribute if it is the currently active one.</p><p>The next bug was that I was getting rate limited when retrieving the artist art images from Spotify. I figured it out because I was getting 429 status codes and I compared it to the Spotify developer documentation:</p><p><a href="https://beta.developer.spotify.com/documentation/web-api/">Web API | Spotify for Developers</a></p><p>I read the documentation a lot closer and apparently I am supposed to use a different endpoint for when I want to get bulk artist and album information. There is a get several artists endpoint that I had to switch to. The endpoint requires a comma-separated list of IDs as a parameter and a max of 50 ids. So I wrote a networking function to loop through my artists and retrieve their album art.</p><p>I also created my app icon in Sketch. It was very intuitive and easy to do. Here is the final result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*4ca1u0C5SPgJSVQbKv8k1g.png" /></figure><p>Finally I connected my app to Fabric and sent out an invitation for some friends and family to join my beta testing. I need to gather some device UDIDs and also get an Apple Developer Account before the testing can begin.</p><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=799f3f264afc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 17 — MVC Pattern Refactoring]]></title>
            <link>https://medium.com/@hsummers96/summer-day-17-mvc-pattern-refactoring-59eea315ae2e?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/59eea315ae2e</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Fri, 18 May 2018 21:21:01 GMT</pubDate>
            <atom:updated>2018-05-18T21:21:01.642Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*tjGJeiSuSamMNgaRJqzznQ.jpeg" /></figure><p>So yesterday I finished all the features in the app and now the next step is refactoring. I watched a video two days ago on how to do UIScrollView programmatically. Starting around 9:38 however he explained how to separate the view from the controller in order to follow the MVC pattern. This eliminates all the view code from the controller class and makes it a lot shorter. The part in the video that I’m talking about is here:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPxPnW3ueQE4%3Fstart%3D578%26feature%3Doembed%26start%3D578&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPxPnW3ueQE4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPxPnW3ueQE4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/852aaf48f5823b17ce78ceac837f7e99/href">https://medium.com/media/852aaf48f5823b17ce78ceac837f7e99/href</a></iframe><p>The steps are as follows:</p><ol><li>Move all your view code to a class that extends UIView like so:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/220bf8ceaae384add4e6ef258912c279/href">https://medium.com/media/220bf8ceaae384add4e6ef258912c279/href</a></iframe><p>2. Add a viewController property to the UIView class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29b22051e6c5f68880655d878e98c30f/href">https://medium.com/media/29b22051e6c5f68880655d878e98c30f/href</a></iframe><p>As stated in the video make sure to set the property to weak in order to prevent a memory retention cycle due to the double reference when we assign the property in the ViewController in a later step.</p><p>3. Add the view to the ViewController:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d9111fa1750eea2fda4181f123c83e4/href">https://medium.com/media/9d9111fa1750eea2fda4181f123c83e4/href</a></iframe><p>4. Assign the viewController property to the view in the viewDidLoad of the ViewController:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8ad3d4c011263ac8dea4b80e1b5bc42/href">https://medium.com/media/c8ad3d4c011263ac8dea4b80e1b5bc42/href</a></iframe><p>And thats it! I then did this for all my ViewControllers. This refactoring process has made my code look so much cleaner. Tomorrow I will continue working on the refactoring process.</p><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59eea315ae2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 16 — Programmatic UICollectionView and Activity Indicators]]></title>
            <link>https://medium.com/@hsummers96/summer-day-16-programmatic-uicollectionview-and-activity-indicators-cea0dbbebb17?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/cea0dbbebb17</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Thu, 17 May 2018 21:33:34 GMT</pubDate>
            <atom:updated>2018-05-17T21:33:34.420Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*575u0LdoVd-oH4xqyrQbKA.jpeg" /></figure><p>Today I worked on finishing my SettingsViewController. This entailed creating a programmatic horizontal UICollectionViewController in order to display my tutorial gifs. It was a little tricky to do programmatically because I was using a UICollectionView inside of a UIViewController instead of a UICollectionViewController. Here is the process for making a collection view programmatically:</p><ol><li>Instantiate the UICollectionView with a UICollectionViewFlowLayout:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7086d4795c4f2ec4be9ff3c9be5ba346/href">https://medium.com/media/7086d4795c4f2ec4be9ff3c9be5ba346/href</a></iframe><p>The main things to take away is you need to set the itemSize for the cells, the delegate and datasource, register the cells, and create the UICollectionViewFlowLayout. Also don’t forget to set translatesAutoresizingMaskIntoConstraints equal to false. There are a lot of things you have to set which makes it a little tricky if you have never done it before.</p><p>2. Add the collection as a subview just like you would do any other view.</p><pre>contentView.addSubview(collectionView)</pre><pre>collectionView.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 15.0).isActive = true</pre><pre>collectionView.heightAnchor.constraint(equalToConstant: 250).isActive = true</pre><pre>collectionView.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 15.0).isActive = true</pre><pre>collectionView.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: 15.0).isActive = true</pre><p>3. Extend the ViewController with UICollectionViewDelegate and UICollectionViewDataSource. Then implement the methods:</p><pre>class SettingsViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource { </pre><pre>... </pre><pre>}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f39f5ba91fe611ebcd9ecf46950a31d8/href">https://medium.com/media/f39f5ba91fe611ebcd9ecf46950a31d8/href</a></iframe><p>One important thing to note is to make sure to do the dequeueReusableCell method instead of just instantiating your Cell normally.</p><p>And thats how I made a programmatic collection view inside of a standard ViewController! Here is the finally result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*JullHkRiK9YY-W2OvV8HyA.gif" /></figure><p>The next thing I worked on was the activity view and the progress label for when you download your user library. I decided to go with a library for my activity view. I have a philosophy of using as few Pods as possible in my app but when I do here are my criteria:</p><ol><li>The Pod is simple and does one thing very well.</li><li>It has a lot of community use and support (stars and pulls)</li><li>It is stable and updated for new Swift versions (No breaking updates in-between major release versions)</li></ol><p>To be completely honest, I also use Pods when it would take me a ridiculously long time to implement my own solution (e.g. Image caching and loading or gif loading).</p><p>One very popular ActivityView Pod is NVActivityIndicatorView:</p><p><a href="https://github.com/ninjaprox/NVActivityIndicatorView">GitHub - ninjaprox/NVActivityIndicatorView: A collection of awesome loading animations</a></p><p>The library seems to fit all my criteria and the first activity view is very similar to the one Spotify uses. I also made a progress label showing the percent completed. The final loading screen looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*22GmT3i2BRy6IQ-2-Pq1UQ.gif" /></figure><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cea0dbbebb17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 15 — UIScrollView Programmatically]]></title>
            <link>https://medium.com/@hsummers96/summer-day-15-uiscrollview-programmatically-5325b217559d?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/5325b217559d</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Wed, 16 May 2018 21:53:36 GMT</pubDate>
            <atom:updated>2018-05-16T21:53:36.627Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*Yqn1i4duh_HHqaaM5fgNJg.jpeg" /></figure><p>Today I worked on implementing the Settings ViewController. From the beginning I wanted it to be a UIScrollView because in the future if I decide to add more features I would like them all to fit. So I set out to create a UIScrollview programmatically. I watched this video that really helped me out:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPxPnW3ueQE4%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPxPnW3ueQE4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPxPnW3ueQE4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/41da23d1765983c2d610b57ab7b53b9a/href">https://medium.com/media/41da23d1765983c2d610b57ab7b53b9a/href</a></iframe><p>The main idea is that you nest the UIScrollView in the main view and then you nest a content view inside of the UIScrollView. You then put everything in the content view and it scrolls. One bug I ran into was none of my buttons were working when done in the way in the video. I realized it was probably due to some uncertain UI placement and sure enough when I set the centerX and centerY for both the scrollView and the contentView everything worked out. This is the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e81f6908aa1075ae34e6499b794c14/href">https://medium.com/media/25e81f6908aa1075ae34e6499b794c14/href</a></iframe><p>One fun thing I learned today is the live view on Playgrounds. You can make a layout programmatically and see your changes live. I found it accidentally in this StackOverflow post:</p><p><a href="https://stackoverflow.com/questions/44931898/using-scrollview-programmatically-in-swift-3">Using ScrollView Programmatically in Swift 3</a></p><p>Tomorrow I will be finishing the SettingsViewController.</p><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5325b217559d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 14 — Transition Animation and Gif loading]]></title>
            <link>https://medium.com/@hsummers96/summer-day-13-transition-animation-and-gif-loading-b57f3d8c9dd2?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/b57f3d8c9dd2</guid>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Tue, 15 May 2018 22:02:51 GMT</pubDate>
            <atom:updated>2018-05-18T21:22:37.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2rpgjiXPEH43Bgb_jykH4g.jpeg" /><figcaption>Blue Duiker</figcaption></figure><p>Today I worked on implementing transition animations in my app. I wanted the next view controller in the on-boarding process to slide in from the right and the current screen to slide out to the left. I was able to accomplish this affect using this code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fff3ac391e8a19101c8c41b58a5c2b87/href">https://medium.com/media/fff3ac391e8a19101c8c41b58a5c2b87/href</a></iframe><p>The next thing I worked on was showing local gifs in the app as a tutorial. I used SwiftGif and it made it really easy. Here is a link to their Github:</p><p><a href="https://github.com/swiftgif/SwiftGif">GitHub - swiftgif/SwiftGif: [UNMAINTAINED] 🌠 A small UIImage extension with gif support</a></p><p>Here is a gif of the animation and the gifs in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*kVF-iJsVPdn4gBrad2xk8A.gif" /></figure><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b57f3d8c9dd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 13 — NSFetchedResultsController Deleting and On-Boarding]]></title>
            <link>https://medium.com/@hsummers96/summer-day-13-nsfetchedresultscontroller-deleting-and-on-boarding-32489a55812c?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/32489a55812c</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Tue, 15 May 2018 01:01:14 GMT</pubDate>
            <atom:updated>2018-05-15T01:01:14.846Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-l77NTicjp7NyymuOcsMYQ.jpeg" /></figure><p>Today I worked on deleting albums from the database. I read this article on how deleting an entity will affect entities it is related to:</p><p><a href="https://cocoacasts.com/core-data-relationships-and-delete-rules">Core Data Relationships and Delete Rules</a></p><p>My goal was when a user deleted an Album for the Artist associated with it to remain unaffected unless all Albums pointing to it were deleted. I was not able to achieve this behavior with the default cascading and denying delete rules so I made a custom delete rule using this stack overflow post as a guide:</p><p><a href="https://stackoverflow.com/questions/9707971/core-data-delete-rule-to-many-relationship-delete-when-empty">Core Data delete rule -- to-many relationship, delete when empty</a></p><p>This is the resulting code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09c4e0d8ed3c8ccf0bc5ddb952396f89/href">https://medium.com/media/09c4e0d8ed3c8ccf0bc5ddb952396f89/href</a></iframe><p>I then started working on the On-Boarding that will be shown during the first startup of the app. I worked on the layout today and tomorrow I am going to work on the custom transition animations. I did, however, read this guide that I will use a reference:</p><p><a href="https://www.raywenderlich.com/173576/ios-animation-tutorial-custom-view-controller-presentation-transitions-3">iOS Animation Tutorial: Custom View Controller Presentation Transitions</a></p><p>These are the screenshots:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*ZoO0L6QfyJTHdeKn4MlVIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*4ZfcpbFEVKyeuTyezPueuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*NNr28iFW-swr84GZNK8E-A.png" /></figure><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32489a55812c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 12 — Custom Modal]]></title>
            <link>https://medium.com/@hsummers96/summer-day-12-custom-modal-b062df0b2b75?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/b062df0b2b75</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Mon, 14 May 2018 02:19:07 GMT</pubDate>
            <atom:updated>2018-05-14T02:19:07.030Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FoD3YszXY_8YKu3a_qULzQ.png" /></figure><p>Today I worked on creating a custom modal that pops up when you want to add a new Album to your library. I wanted to make my own ActionSheet that comes up from the bottom of the screen whenever a new album is identified. In order to do this I created a view controller with the layout that I wanted. Then I instantiated my ViewController like so:</p><pre>let addAlbumViewController = AddAlbumViewController()</pre><pre>addAlbumViewController.modalPresentationStyle = .overCurrentContext</pre><p>I then set the view’s alpha value to zero. Then I started building a little card at the bottom of the screen. When presented this ViewController behaves very closely to the default action sheet.</p><p>Next I wanted the ability to dismiss the custom action sheet by touching outside of the action sheet view. I did this by creating a “background” view that took up the entire screen above the action sheet view. Then I added a gesture recognizer like so:</p><pre>let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(backgroundTouched))</pre><pre>backgroundView.addGestureRecognizer(gestureRecognizer)</pre><p>I also wanted to add haptic feedback whenever the action sheet is displayed. I used these few lines of code to achieve this:</p><pre>let impact = UIImpactFeedbackGenerator()</pre><pre>impact.impactOccurred()</pre><p>Finally, I wanted to make sure the album does not already exist in the database so I made an extension to the Album NSManagedObject class. I added a static method to this extension that takes an externalUrl (I am using this as the id because it is unique) and a NSManagedObjectContext. I then performed a fetch with the externalUrl and if any exist I return true and if it does not I return false.</p><p>The new action sheet looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*ZMPatYtEnRGPdzIa4mA0uA.png" /></figure><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b062df0b2b75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 11 — Adding Albums from Clipboard]]></title>
            <link>https://medium.com/@hsummers96/summer-day-11-adding-albums-from-clipboard-615c25408bec?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/615c25408bec</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Sat, 12 May 2018 21:49:55 GMT</pubDate>
            <atom:updated>2018-05-12T22:05:32.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*y7eA_OfTGRvpPZT2RrCOLA.jpeg" /></figure><p>Today I worked on adding new albums from Spotify. My idea has these steps:</p><ol><li>The user copies the share link from the album on Spotify.</li><li>They then navigate to my app.</li><li>The app identifies that there is a Spotify album link in the Clipboard and fetches the album data from the Spotify api.</li><li>The user is presented with an action sheet asking to add the album to the library.</li><li>If “Add’” is pressed the album is added to core data.</li></ol><p>I accomplished all of these steps today. I accessed the clipboard data with the following line of code:</p><pre>let clipboard = UIPasteboard.general.string</pre><p>I then parsed this string to get only the album id like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a9939531dea4da6fe6e45d2feac8552/href">https://medium.com/media/9a9939531dea4da6fe6e45d2feac8552/href</a></iframe><p>Here is the action sheet displaying the information retrieved from the API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*qRfmj7O1DzQsB50Ps2DOtQ.png" /></figure><p>Tomorrow I am going to make a custom Action Sheet that matches the theme of the app. I will also try to make it so that if the album already is in the database to not show the action sheet.</p><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=615c25408bec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 10 — NSFetchedResultsController SearchBar and Section Scrolling]]></title>
            <link>https://medium.com/@hsummers96/summer-day-10-nsfetchedresultscontroller-searchbar-and-section-scrolling-27c3739a04f1?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/27c3739a04f1</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Fri, 11 May 2018 23:16:17 GMT</pubDate>
            <atom:updated>2018-05-11T23:16:17.336Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQOxWKGZ8ZUvhlz-IBSgfg.png" /></figure><p>The first thing I did today was fix a threading bug I had yesterday. When I tried to download the album art the app would crash. The reason was I was calling a save on my main context in the closure block of an asynchronous API call. I simply wrapped the method’s onComplete closure in a DispatchQueue.async.main closure block and the app no longer crashes.</p><p>The next thing I did today was work on getting a search bar in my NSFetchedResultsController. I first read the following StackOverflow post:</p><p><a href="https://stackoverflow.com/questions/33404482/updating-fetchedresultscontroller-for-predicate-set-by-uisearchbar">Updating fetchedResultsController for predicate set by UISearchBar</a></p><p>Using this information I implemented the updateSearchResults method like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc6657b81dfb97d56064114e02a65856/href">https://medium.com/media/dc6657b81dfb97d56064114e02a65856/href</a></iframe><p>I also made it so that when you click on the tab bar the tableView scrolls to the top using this StackOverflow post as a reference:</p><p><a href="https://stackoverflow.com/questions/22392151/tap-tab-bar-to-scroll-to-top-of-uitableviewcontroller">Tap tab bar to scroll to top of UITableViewController</a></p><p>My code looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae115db59929e49b27eaf3895fd0d547/href">https://medium.com/media/ae115db59929e49b27eaf3895fd0d547/href</a></iframe><p>Make sure to set the delegate for the tabBarController!</p><p>The last thing I did was add the scroll bar on the side that takes you to the section titles. I was confused on how to do this at first because I was using NSFetchedResultsController. It turns out it is a built in capability in the controller. Here is the StackOverflow post that helped me figure it out:</p><p><a href="https://stackoverflow.com/questions/15943998/a-z-index-from-nsfetchedresultscontroller-with-individual-section-headers-within">A-Z Index from NSFetchedResultsController with individual section headers within each letter?</a></p><p>These are the steps:</p><ol><li>Set the sectionNameKeyPath:</li></ol><pre>let frc = NSFetchedResultsController(fetchRequest: request, managedObjectContext: context, sectionNameKeyPath: &quot;name&quot;, cacheName: nil)</pre><p>When you initialize your NSFetchedResultsController make sure to set the sectionNameKeyPath. This value should represent a field of your NSManagedObject that your controller is based on. I wanted my sections to be divided into the Artist names so I passed in “name.”</p><p>2. Implement numberOfSections correctly:</p><pre>override func numberOfSections(in tableView: UITableView) -&gt; Int {</pre><pre>    if let count = fetchedResultsController.sections?.count {</pre><pre>       return count</pre><pre>    } else {</pre><pre>       return 1</pre><pre>    }</pre><pre>}</pre><p>I know I have a habit of just throwing in return 1 in this method whenever I don’t have sections in my tableView so make sure you are actually giving it the sections from the controller</p><p>3. Implement sectionIndexTitles:</p><pre>override func sectionIndexTitles(for tableView: UITableView) -&gt; [String]? {</pre><pre>    return fetchedResultsController.sectionIndexTitles</pre><pre>}</pre><p>4. Implement sectionForSectionIndexTitles:</p><pre>override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -&gt; Int {</pre><pre>       return fetchedResultsController.section(forSectionIndexTitle:    title, at: index)</pre><pre>}</pre><p>Screenshots:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*IAHbiWv7tjktXwoM6_Vykw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Uw9u9W_bToAHQ2VzC7TFTg.png" /><figcaption>Showing off the side scroll bar and the search bar.</figcaption></figure><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27c3739a04f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer Day 9 — Finishing Artist Page]]></title>
            <link>https://medium.com/@hsummers96/summer-journal-day-9-8a74d7a219d0?source=rss-26d84c484230------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a74d7a219d0</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Harry Summers]]></dc:creator>
            <pubDate>Fri, 11 May 2018 03:21:48 GMT</pubDate>
            <atom:updated>2018-05-11T20:33:26.916Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*6xPFosMOzVQHsAg1OyWqSQ.jpeg" /></figure><p>Today I focused on finishing the UI for the artist TableView. The first thing I did was fix the duplication that I was seeing yesterday. I did a check on the database to see if an artist with that ID already exists. If it does I would add the album to the list of albums for that artist and if it didn’t I would create the artist and then set it. The main bug I had was that in the fetch predicate I used:</p><pre>request.predicate = NSPredicate(format: &quot;id = %s&quot;, id)</pre><p>instead of the correct version:</p><pre>request.predicate = NSPredicate(format: &quot;id = %@&quot;, id)</pre><p>You are supposed to use %@ instead of %s for the string format. I had it confused with other languages.</p><p>The next thing I worked on was loading in the album arts. After all the artist information is loaded into the database I fire off a separate loop of API requests for the Artist object. This is done because the artist image url is not given in the Album Library GET endpoint. I also made the artist image UIs circular by setting the corner radius of the UIImageView to half of the height. Here is how the artist tab looks like now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*UvCfSD49EuTZMm174E_dhA.png" /></figure><p>Github Link:</p><p><a href="https://github.com/harrysummers/Infinite-Library">harrysummers/Infinite-Library</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a74d7a219d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>