<?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 Mazen Kilani on Medium]]></title>
        <description><![CDATA[Stories by Mazen Kilani on Medium]]></description>
        <link>https://medium.com/@mazenkilani?source=rss-fbfa6ba21b5f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2brV6mBzZc77H44i.jpg</url>
            <title>Stories by Mazen Kilani on Medium</title>
            <link>https://medium.com/@mazenkilani?source=rss-fbfa6ba21b5f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 19:55:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mazenkilani/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[Swift Map of a Location Address]]></title>
            <link>https://medium.com/geekculture/swift-map-of-a-location-address-dadb167786d8?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/dadb167786d8</guid>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Thu, 15 Jul 2021 15:28:45 GMT</pubDate>
            <atom:updated>2021-07-15T15:28:45.776Z</atom:updated>
            <content:encoded><![CDATA[<p>Swift MapKit Will Display a Map of a Location Street Address</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*uWXfcck4W_nwZ8W2bh9oaQ.png" /><figcaption>AppsGym ToDo App Map of a Location Address</figcaption></figure><h3>Scenario</h3><p>Our app ToDo Note Details view will have a map button, where the user can tap to show the map of the Location text field address.</p><h3>Technique</h3><p>We shall utilise the <strong>MapKit</strong> framework, <strong>GLGeocoder()</strong>, and geocoding. <strong>Geocoding</strong> is the process of converting addresses (like a street address) into geographic coordinates (like latitude and longitude), which you can use to place markers on a map, or position the map. Reverse geocoding is the process of converting geographic coordinates into a human-readable address (ref Google).</p><p>In our Map view, we shall convert the Location address text to a <strong>placemark</strong> coordinates, which are then used to position and draw the map. Hence, we shall utilise the <strong>GLGeocoder geocodeAddressString(..)</strong> function, with location text as parameter, to retrieve a placemark coordinates, then use an <strong>MKPointAnnotation() </strong>to draw a map pin (annotation) with the location address as the pin title.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*RupILp0B6vHU_Mcex_z3fA.gif" /><figcaption>GIF Details Map Button Segues to the Map View</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects. The code snippets below can be used with minimal customisation.</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/todo-lists-notifications-multimedia/">ToDo</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8todo/id1375224765">8ToDo</a>), and you can download the complete <a href="https://appsgym.com/downloads/">Xcode</a> project on AppsGym.com, for free.</p><h3>User Interfaces</h3><p>We need a <strong>map</strong> <strong>UIButton </strong>on the Details view, which will segue to the Map view. The Note Map view will show the map over the whole screen, using an <strong>MKMapView, and </strong>highlighting a red pin (annotation) with its title as the location address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*zU4XO2QXEGFLtAvYOStykw.png" /><figcaption>ToDo Details View Map Button</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*6twLhzmQwi-pSOP2-nv5LQ.png" /><figcaption>Map View Pin with Address</figcaption></figure><p>The Details and Map <strong>storyboards</strong> show the Details view Map button and a simple ‘Show’ segue, while the Map view has only an <strong>MKMapView</strong> covering the whole view area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*Z_xHlGbh5_lokzMcP94pNg.png" /></figure><p>Note: In your app, you may choose a map view which covers part of the view, or even as a pop-up modal over the Details view (ref our article on Swift Floating Pop-Up).</p><h3>Logic</h3><p><strong>NoteDetailsViewController.swift</strong> will contain a map UIButton, which will initially show if a location has been entered (by changing the button image, from grey to colourful). If there is a Location field text, the button will segue, using Show ‘Push’, to the <strong>NoteMapViewController.swift</strong>. We can establish the segue directly on the Storyboard, or programmatically in a UIButtonAction. Our model app uses direct storyboard segue, as it’s a relatively simple setup. <em>Note</em>: If you are using <em>SwiftUI</em>, then use the programmatic approach.</p><p>As we need the actual location address in NoteMapViewController, we can either pass, via the segue, the Location text field value, or the complete note object. The object approach allows us to access all the note other attributes, such as title, folder, image, etc. In our model app, we shall pass the note object to allow for future flexibility.</p><p>The <strong>NoteMapViewController.swift </strong>acts as the<strong> <em>MKMapViewDelegate</em></strong>, to draw the map and position the annotation pins.</p><p>We shall pass the location attribute with the note object, so we shall use <strong>geocodeAddressString(..)</strong> to convert the location text string to a <a href="https://developer.apple.com/documentation/corelocation/clplacemark"><strong>CLPlacemark</strong></a>, and then extract the placemark coordinates to position the annotation pin.</p><p><strong><em>Note</em></strong>: Should you choose a <em>UITextView</em> in your app, rather than a UITextField, then you will need to concatenate the address components into a single text string, which you then submit as a parameter to geocodeAddressString(..).</p><h3>Code</h3><p><strong>NoteDeatils ViewController.swift</strong> <strong>Map Button &amp; Segue to Map View</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fbe450d1e1a8fdaa137f7fbcb8f695e/href">https://medium.com/media/4fbe450d1e1a8fdaa137f7fbcb8f695e/href</a></iframe><p><strong>NoteMapViewController.swift</strong> <strong>Initialise</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97ac5fb4f3ebf82f16d3a37040945009/href">https://medium.com/media/97ac5fb4f3ebf82f16d3a37040945009/href</a></iframe><p>NoteMapViewController.swift <strong>viewDidLoad()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/255e623225be7f6c634d38dc1d52c46a/href">https://medium.com/media/255e623225be7f6c634d38dc1d52c46a/href</a></iframe><p>NoteMapViewController.swift <strong>Delegate Methods</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0323f459abe8d3f7031c4adffdc80a75/href">https://medium.com/media/0323f459abe8d3f7031c4adffdc80a75/href</a></iframe><p><strong>What if the Location text is invalid?</strong></p><p>If the location field text is invalid (e.g., ‘BlahBlah’), then MapKit will draw a default map based on the user overall location, usually the country view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*JugyxIRkRhZtExnwj_4KMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*mmphTYVwYOx70Haw4BWPdQ.png" /><figcaption>Default Map if Note Location Field Has Invalid Text (User in Australia)</figcaption></figure><p>The article covered the complete setup, logic, and code to display a map of the note location address text field. The note details view map button will segue to a dedicated map view, which acts as the MKMapViewDelegate and draws the map and any annotated pins. Hope you find the article useful for your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dadb167786d8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/swift-map-of-a-location-address-dadb167786d8">Swift Map of a Location Address</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift ‘Find Me’ Address Location Tracker]]></title>
            <link>https://medium.com/geekculture/swift-find-me-address-location-tracker-86d0bca93ab3?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/86d0bca93ab3</guid>
            <category><![CDATA[location]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[maps]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Thu, 08 Jul 2021 08:02:43 GMT</pubDate>
            <atom:updated>2021-07-09T03:58:06.654Z</atom:updated>
            <content:encoded><![CDATA[<p>The ‘Find Me’ Feature Will Find and Display the Address of the User Phone Location</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*zoPdtEVeBelHe9rt5ydZNw.png" /><figcaption>AppsGym ToDo App Find Me Feature</figcaption></figure><h3>Scenario</h3><p>Our app main ToDo view will have a Location text field, where the user can enter a street address. Optionally, the app will also provide a ‘Find Me’ button. The user will tap/touch the button, authorise the location tracking, and the app will retrieve the address of the current user location and automatically populate the address in the Location text field.</p><h3>Technique</h3><p>We shall utilise the <strong>Core Location</strong> framework, <strong>CLLocationManager()</strong>, and Reverse Geocoding. <strong>Geocoding</strong> is the process of converting addresses (like a street address) into geographic coordinates (like latitude and longitude), which you can use to place markers on a map, or position the map. <strong>Reverse geocoding</strong> is the process of converting geographic coordinates into a human-readable address (ref Google).</p><p>In our view, the Find Me button will convert the device location coordinates into a Location address text (reverse geocoding). Hence, we shall utilise the <strong>GLGeocoder.reverseGeocodeLocation(..)</strong> function, retrieve a <strong>CLPlacemark()</strong>, a user-friendly description of a geographic coordinate, then construct the address in a 1-line text field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*z3Qdn7CVbjisVs0AJGTbsw.gif" /><figcaption>GIF AppsGym ToDo Find Me Button and Address</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects. The code snippets below can be used with minimal customisation (your app button and text field).</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/todo-lists-notifications-multimedia/">ToDo</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8todo/id1375224765">8ToDo</a>), and you can download the complete <a href="https://appsgym.com/downloads/">Xcode</a> project on AppsGym.com, for free.</p><h3>User Interfaces</h3><p>We need a <strong>UITextField</strong> and a Find Me <strong>UIButton</strong>. The text field will store the street address, whether the user adds manually (by typing) or automatically by the Find Me button reverse geocoding logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*_g4CE_pCBnactLMk2C1J6Q.png" /><figcaption>AppsGym ToDo Location Text Field and Find Me Button</figcaption></figure><h3>Logic</h3><p><strong>NoteViewController.swift</strong> will act as the <strong>CLLocationManagerDelegate</strong>, so it can retrieve the location information obtained by the CLLocationManager.</p><p>The <strong>findMeButtonAction()</strong> will trigger the <strong>findMe() </strong>function, which will instantiate the <strong>CLLocationManager()</strong>, request authorisation, and start updating the locations, adding each location to an array, locations[]. We shall select only the first entry <strong>locations[0]</strong> and then stop the location tracking.</p><p>Now that we have the location information, we shall use <strong>reverseGeocodeLocation(..)</strong> to convert the location to a <a href="https://developer.apple.com/documentation/corelocation/clplacemark"><strong>CLPlacemark</strong></a>, a pre-defined variable that stores the components of an address. We shall check each component, and if there is a value, then store it in a corresponding text variable. The final address will be the concatenation of all the components.</p><p>The CLPlacemark main components are: subThoroughfare, thoroughfare, subLocality, locality, subAdministrativeArea, postalCode and Country.</p><p><strong><em>Note</em></strong>: Should you choose a <em>UITextView</em> in your app, rather than a UITextField, then you can include the address on multiple lines, each line for a component, within the text view.</p><h3>Code</h3><p><strong>NoteViewController.swift</strong> <strong>Initialise &amp; findMeButtonAction()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b026bfc48d4e825bd4a3693f48b8d8f8/href">https://medium.com/media/b026bfc48d4e825bd4a3693f48b8d8f8/href</a></iframe><p><strong>NoteViewController.swift findMe()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a04b784183db1bfbe470aa0ba1ae5c13/href">https://medium.com/media/a04b784183db1bfbe470aa0ba1ae5c13/href</a></iframe><p><strong>NoteViewController.swift locationManager(..)</strong> Delegate method</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/220240b9c15c55f7c997a693f91f6848/href">https://medium.com/media/220240b9c15c55f7c997a693f91f6848/href</a></iframe><p><strong>Info.plist</strong> entries for location tracking authorisation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*P-JkRMr4j4Qi-p9gbOMyVg.png" /><figcaption>Info.plist Privacy for Location Tracking Authorisation</figcaption></figure><p>The article covered the complete logic and code to allow the user to either enter a location address or retrieve the current location address automatically. We call the retrieval of a location address reverse geocoding. The user will tap a Find Me button and authorise the location tracking, the app will then retrieve the location coordinates, convert to a street address and populate the Location text field. Hope you find it useful in your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86d0bca93ab3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/swift-find-me-address-location-tracker-86d0bca93ab3">Swift ‘Find Me’ Address Location Tracker</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Date/Time Selective Repeats (Every Mon, Wed, and Friday, etc.)]]></title>
            <link>https://mazenkilani.medium.com/swift-date-time-selective-repeats-every-mon-wed-and-friday-etc-80fe56451bee?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/80fe56451bee</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[calendar]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Fri, 02 Jul 2021 00:28:22 GMT</pubDate>
            <atom:updated>2021-07-02T00:28:22.685Z</atom:updated>
            <content:encoded><![CDATA[<p>Selective Repeats will Schedule a Repeat of an Event or Notification According to a User-Specified Days of the Week (Mon to Sun).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*k9s_otUcVZvmK-m9YScTrw.png" /><figcaption>AppsGym ToDo Selective Repeat of Days of the Week</figcaption></figure><h3>Scenario</h3><p>Our app will schedule a repeating Remind Me date/time notification, based on a user-specified <strong>days of the week</strong>. The user should be able to select any combination of days (Mon, Tue, Wed, Thu, Fri, Sat, and Sun).</p><h3>Technique</h3><p>We shall utilise 7 UIButtons, a button for each day. The user can toggle each button off/on to indicate day selections. Upon save, we check each button status (off/on) and construct the repeat label showing ‘on’ days.</p><p>The Repeat View will implement a <strong>Delegate Protocol</strong>, with a function to return the user specified days of the week values back to the calling view. In our app, the ToDo Note view, which contains the Remind Me date/time field, will be the calling view. Hence, the ToDo Note view will act as the Repeat View Delegate and implement the Repeat View Delegate functions, which allows it to receive the selected days of the week values.</p><p>We trigger the logic to actually re-schedule the next reminder date/time when the user flags the current ToDo as done (completed). This will be detailed in a future article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*rB-0XT5s_KNdLNmpoDXtlQ.gif" /><figcaption>GIF AppsGym ToDo Showing Selective Repeats of Days of the Week</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects.</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/todo-lists-notifications-multimedia/">ToDo</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8todo/id1375224765">8ToDo</a>), and you can download the complete <a href="https://appsgym.com/downloads/">Xcode</a> project on AppsGym.com, for free.</p><h3>User Interfaces</h3><p>The<strong> <em>Todo Note view</em></strong> will show a Remind Me<strong> Repeat UIButton w</strong>hich will navigate to the Repeat view, a <strong>UILabel</strong> to show the current repeat setup, and a <strong>Cancel UIButton</strong>, which will erase repeat setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*zPmiXf9w9TttAso-2iQcZA.png" /><figcaption>ToDo Note View (Showing Remind Me Date/Time and Repeat Sections)</figcaption></figure><p>The <strong><em>Repeat view</em></strong> will show the Selective Days of the Week (Mon, Tue, Wed, Thu, Fri, Sat, and Sun), allow the user to tap each day’s UIButton to toggle the values (On/Off, visually changing the button image), and return the values to the calling view upon save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*W_Yh3ETcPM6NL7VRoKZGzw.png" /><figcaption>ToDo Repeat View (Showing Selective Section)</figcaption></figure><h3>Logic</h3><p><strong>NoteViewController.swift</strong> will contain a Repeat UIButton and a UITextField. The <strong>UIButton</strong> navigates to the RepeatViewController.swift, and the <strong>UITextField</strong> shows the string concatenation of the user-selected days of the week (e.g., ‘Mon Wed Fri’ or ‘Sat Sun’).</p><p>The UIButton triggers the <strong>“showRepeat” segue</strong> in the Storyboard, and passes the current values of repeat days of the week, if any. This allows the RepeatViewController.swift to show the current days selected, if any.</p><p>The NoteViewController acts as the RepeatViewControllerDelegate, linking the 2 views.</p><p>The <strong>RepeatViewController.swift </strong>implements the <strong>protocol</strong> <strong>RepeatViewControllerDelegate</strong> with its function repeatSelectiveOrPeriodic(..), as the same RepeatViewController also handles the (Cycle and Interval) Periodic logic (detailed in a prior Medium story).</p><p>The RepeatViewController.swift initialises <strong>7 Boolean variables</strong> (for each day of the week, e.g., alarmOnWed), and shows <strong>7 UIButtons</strong>, each acting as a toggle switch (on/off) upon tap, visually changing the button image. The view also contains a <strong>Save</strong> switch to save the user-selected values, and a function that is triggered upon the ‘<strong>Back</strong>’ arrow button to pass the user-selected days back to the calling view.</p><h3>Code</h3><p><strong><em>Note</em></strong>: The app RepeatViewController handles both Periodic (every hour, day, …) and Selective (specific days of the week). In this article, the code snippets below have been ‘trimmed’ to show only the Selective part, allowing focus on the article scope. Please refer to our other article on Periodic Repeats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*zPmiXf9w9TttAso-2iQcZA.png" /><figcaption>NoteViewController.swift Showing Repeat Button and Label</figcaption></figure><p><strong>NoteViewController.swift: Initialise, Button Action, and Navigation.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c4ddfa67d02b539040051c03ef7c954/href">https://medium.com/media/6c4ddfa67d02b539040051c03ef7c954/href</a></iframe><p><strong>RepeatViewController.swift </strong>Initialise Variables, Arrays, and UIButtons</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*OcyPpI3cb7cLx7svAXdtcg.png" /><figcaption>Repeat View Controller Selective Repeat Days of the Week Buttons</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa16bd84080da64e3be2daec2b85b40a/href">https://medium.com/media/fa16bd84080da64e3be2daec2b85b40a/href</a></iframe><p>RepeatViewController.swift <strong>viewDidLoad() ToDo Note Title</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a4e734b560d4a1b67fdcaa966c421a6/href">https://medium.com/media/9a4e734b560d4a1b67fdcaa966c421a6/href</a></iframe><p>RepeatViewController.swift <strong>viewWillAppear() Show current button values.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9e47556c5a90fa5233224a9fcf03791/href">https://medium.com/media/f9e47556c5a90fa5233224a9fcf03791/href</a></iframe><p>RepeatViewController.swift <strong>setAllSelectiveDaysToWhite()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04e70245592589dbdef14fc0bda14ca4/href">https://medium.com/media/04e70245592589dbdef14fc0bda14ca4/href</a></iframe><p>RepeatViewController.swift <strong>setAllSelectiveDaysImages()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/137d2bf337cde6189827e56e2d2ae0cc/href">https://medium.com/media/137d2bf337cde6189827e56e2d2ae0cc/href</a></iframe><p>RepeatViewController.swift <strong>Selective Days Alarms</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13ec3eae2187320db005006846335fbd/href">https://medium.com/media/13ec3eae2187320db005006846335fbd/href</a></iframe><p>RepeatViewController.swift <strong>willMove(..) Return to Calling View.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7eebd2fed8f7ab3de44fb31ad70a604/href">https://medium.com/media/e7eebd2fed8f7ab3de44fb31ad70a604/href</a></iframe><p>The article covered the complete setup, logic, and code to implement a comprehensive date/time selective days of the week repeat feature. The user can select any combination of days, and we store the selections on the ToDo Note record to trigger the events or notifications on the specified dates and times. Hope you find the article useful for your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80fe56451bee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Video: Record, Store, and Play]]></title>
            <link>https://medium.com/swift2go/swift-video-record-store-and-play-75527693809b?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/75527693809b</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Fri, 25 Jun 2021 06:39:40 GMT</pubDate>
            <atom:updated>2021-06-25T06:39:40.118Z</atom:updated>
            <content:encoded><![CDATA[<p>Users Can Record Video Files, Store on Device and Core Data, and Play from a List.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*oyWneVB1Eh3fGxM4j7zf5g.png" /><figcaption>AppsGym Media Menu Navigation to Videos View Actions</figcaption></figure><h3>Scenario</h3><p>Our ToDo app allows users to record video files, store them on the device File Manager, as well as Core Data linked to a ToDo Note, and play them as needed from a ToDo Videos list.</p><h3>Technique</h3><p>We shall utilise 3 <strong>frameworks</strong>:</p><blockquote><strong>AVKit</strong> framework, for its video player functions,</blockquote><blockquote><strong>Photos</strong> framework, for its Photo Library functions (to store the videos),</blockquote><blockquote><strong>MobileCoreServices</strong>, for its kUTTypeMovie functions</blockquote><p>We shall also utilise 2 <strong>Controllers:</strong></p><blockquote><strong>UIImagePickerController, </strong>to record the video files, and <strong>AVPlayerViewController</strong> (from AVKit), to play the video files.</blockquote><p>We keep records in <strong>Core Data,</strong> linked to the ToDo Note, of all related video files.</p><p>We shall design 3 UIButtons on the Recording view: <strong>Record New Video</strong>, <strong>Select from Library</strong>, and <strong>Play Last Video </strong>(the last recorded video in this session).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*vnRfPehMurY1fJKefZtz0Q.gif" /><figcaption>GIF Record New Video</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects. The code snippets below can be used with minimal customisation.</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/todo-lists-notifications-multimedia/">ToDo</a> model app, published on Apple’s App Store as <a href="https://apps.apple.com/au/app/8todo/id1375224765">8ToDo</a> (free, no ads).</p><h3>User Interfaces</h3><p>We need <strong>Record, Select, </strong>and<strong> Play UIButtons i</strong>n the video recording section. <em>Note</em>: We do not need a <strong>Save</strong> UIButton, as the UIImagePickerController <strong>Use Video</strong>, once video recording is finished, acts as the save trigger action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*zy-VOv3FLLW6uGAAe8yifQ.png" /><figcaption>Video Menu Actions: Records, Select from Library, and Play</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*6D0xXXpulkTkZ_GIi8c1rw.png" /><figcaption>Videos View Storyboard</figcaption></figure><h3>Logic</h3><p><strong>VideosViewController.swift</strong> will contain all the components to record, select and play the videos, essentially 3 <strong>UIButtons</strong> (Record, Select, and Play). VideosViewController will act as the <strong>UIImagePickerControllerDelegate</strong>, so it can implement its record and cancel functions.</p><p>We start by initialising all the components, and creating instances of UIImagePickerController and AVPlayerViewController.</p><p>We link each button (Record, Select, and Play) with its <strong>UIButton Action </strong>function.</p><p>Furthermore, we utilise the imagePickerController protocol <strong>Delegate</strong> functions:</p><blockquote><strong>didFinishPickingMediaWithInfo: </strong>Tells the delegate that the user picked a still image or movie (we use it to record the video, and trigger the save to Core Data), and</blockquote><blockquote><strong>imagePickerControllerDidCancel: </strong>Tells the delegate that the user cancelled the pick operation (we use it to dismiss the UIImagePickerController if the user cancels the recording).</blockquote><h3><strong>Code</strong></h3><p>The code snippet below from <strong>NoteViewController.swift</strong>, navigating to the VideosViewController, and passing relevant variable values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad228db1dd243ed2fc675ea35f444f8f/href">https://medium.com/media/ad228db1dd243ed2fc675ea35f444f8f/href</a></iframe><p>All code snippets below from <strong>VideosViewController.swift</strong>, shown in sequence, and constitute the complete file.</p><p><strong>Initialise</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8500fe90d3439ff058a1e029475c2c67/href">https://medium.com/media/8500fe90d3439ff058a1e029475c2c67/href</a></iframe><p><strong>viewDidLoad()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51ee30f8c3154b39b654d02a4d80d777/href">https://medium.com/media/51ee30f8c3154b39b654d02a4d80d777/href</a></iframe><p><strong>takeVideoButtonAction(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f385fadc1ff31433a560faaab4eea888/href">https://medium.com/media/f385fadc1ff31433a560faaab4eea888/href</a></iframe><p><strong>viewLibraryButtonAction(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d306770fa63dab42b742b90de81c9ad4/href">https://medium.com/media/d306770fa63dab42b742b90de81c9ad4/href</a></iframe><p><strong>playVideoButtonAction(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab56952ec8fc6372fb112198ef441b1f/href">https://medium.com/media/ab56952ec8fc6372fb112198ef441b1f/href</a></iframe><p><strong>viewDidDisappear(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1954672e503e9b2c9ae70732c2f670d5/href">https://medium.com/media/1954672e503e9b2c9ae70732c2f670d5/href</a></iframe><p><strong>imagePickerController(..) -/- didFinish &amp; didCancel</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2dae7ca3a4b9e7303ff029c796d2e8c/href">https://medium.com/media/e2dae7ca3a4b9e7303ff029c796d2e8c/href</a></iframe><p><strong>noCamera()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71a4a828169fba367201643b87a089d7/href">https://medium.com/media/71a4a828169fba367201643b87a089d7/href</a></iframe><p><strong>Helpers(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33ef2eaf1a7810a4e32c08119adb142c/href">https://medium.com/media/33ef2eaf1a7810a4e32c08119adb142c/href</a></iframe><p>The article covered the complete setup, logic, and code to record, store, and play a videofile. We utilised <strong>AVKit</strong>, <strong>Photos</strong>, and <strong>MobileCoreServices</strong> framworks, and <strong>UIImagePickerController</strong> to record the video and <strong>AVPlayerViewController</strong> to play the video. Then we linked the recorded video file URL to the specific ToDo Note in<strong> Core Data. </strong>Hope you find the article useful for your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75527693809b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swift2go/swift-video-record-store-and-play-75527693809b">Swift Video: Record, Store, and Play</a> was originally published in <a href="https://medium.com/swift2go">Swift2Go</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Audio: Record, Store, and Play]]></title>
            <link>https://medium.com/swift2go/swift-audio-record-store-and-play-af965bf92b26?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/af965bf92b26</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[audio]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Sat, 19 Jun 2021 07:51:24 GMT</pubDate>
            <atom:updated>2021-06-19T07:51:24.357Z</atom:updated>
            <content:encoded><![CDATA[<p>Users Can Record Audio Files, Store in Core Data, and Play from a List.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*P5WdvaPO1KIsYGjYq2hQVQ.png" /><figcaption>AppsGym ToDo Audio Record, Stop, and Play</figcaption></figure><h3>Scenario</h3><p>Our ToDo app allows users to record audio sound files, store them in the device File Manager, as well as Core Data linked to a ToDo Note, and play them as needed from a ToDo Sounds list.</p><h3>Technique</h3><p>We shall utilise the <strong>AVFoundation</strong> framework, <strong>AVAudioRecorder</strong>, and <strong>AVAudioPlayer </strong>to record and play the sound files. Then use the <strong>File Manager</strong> to store the audio sound file URLs and keep records in <strong>Core Data</strong> linked to the ToDo Note of all related sound files.</p><p>We shall design 3 UIButtons on the Recording view: <strong>Record</strong>, <strong>Stop</strong>, and <strong>Play</strong> (the last recorded audio), and change their images to reflect their status (blue if active, grey is inactive). Also, we shall enter a <strong>Title</strong> for the audio recording in a UITextField, show the <strong>Recording Status</strong> in a UILabel, and save using a <strong>Save</strong> UIButton.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*1nKwTJVgB6Ie_odpoBf1fg.gif" /><figcaption>GIF AppsGym ToDo Audio Recording Sounds View</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects. The code snippets below can be used with minimal customisation.</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/todo-lists-notifications-multimedia/">ToDo</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8todo/id1375224765">8ToDo</a>), and you can download the complete <a href="https://appsgym.com/downloads/">Xcode</a> project on AppsGym.com, for free.</p><h3>User Interfaces</h3><p>We need <strong>Record, Stop, </strong>and<strong> Play UIButtons i</strong>n the Audio (Sounds) recording section, a <strong>Save</strong> UIButton, a <strong>Title</strong> UITextField, and a recording <strong>Status</strong> UILabel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*g_Aqeg1xD1lW5zddyccLgQ.png" /><figcaption>Sounds View Controller Recording Layout</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*GV5Ol_URAz1K77maOz4alA.png" /><figcaption>AppsGym ToDo Sounds Storyboard</figcaption></figure><h3>Logic</h3><p><strong>SoundsViewController.swift</strong> will contain all the components to record, stop, play, and title the audio recording, essentially 3 UIButtons (Record, Stop, and Play), a Title UITextField, and a Save UIButton. SoundsViewController will act as the <strong>Delegate</strong> to both AVAudioRecorder and AVAudioPlayer, so it can implement their record and play functions.</p><p>We start by initialising all the components, and creating instances of AVAudioRecorder and AVAudioPlayer. Then we construct the audio file name, and define its unique <strong>URL</strong> directory in the device File Manager. We then set up the recording and playing settings for our current <strong>recording session</strong>.</p><p>We link each button (Record, Stop, and Play) with its <strong>Button Action</strong>, and change the recording status label and button image (blue if active, grey if inactive) to reflect current <strong>recording status </strong>(e.g., Ready to Record, Recording, Recording Completed, Playing).</p><p>Furthermore, we utilise the Delegate functions, <strong>audioRecorderDidFinishRecording</strong> and <strong>audioPlayerDidFinishPlaying</strong> to define the actions at the appropriate time. Then implement the <strong>Save</strong> button action to save to the device directory and to Core Data.</p><p>We implement <strong>helper</strong> functions to:</p><blockquote><em>check microphone authorisation and access,</em></blockquote><blockquote><em>control the keyboard, and</em></blockquote><blockquote><em>highlight Save button only if the user enters a Title.</em></blockquote><h3>Code</h3><p><strong>SoundsViewController.swift</strong> Initialise</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c04d1ae225dcb0b9496031ea1d8526c/href">https://medium.com/media/7c04d1ae225dcb0b9496031ea1d8526c/href</a></iframe><p>SoundsViewController.swift <strong>viewDidLoad()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d24d0dcd26577d2eaf240ab50bba9ca3/href">https://medium.com/media/d24d0dcd26577d2eaf240ab50bba9ca3/href</a></iframe><p>SoundsViewController.swift<strong> recordButtonAction(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2280513c907b97c2a99ed6c488880c69/href">https://medium.com/media/2280513c907b97c2a99ed6c488880c69/href</a></iframe><p>SoundsViewController.swift <strong>stopButtonAction(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1da4988723fbd836e142b748de746cb9/href">https://medium.com/media/1da4988723fbd836e142b748de746cb9/href</a></iframe><p>SoundsViewController.swift <strong>playButtonAction(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f79da02ed80c3f3bd64e4ccc27652cf/href">https://medium.com/media/7f79da02ed80c3f3bd64e4ccc27652cf/href</a></iframe><p>SoundsViewController.swift <strong>audioRecorderDidFinishRecording(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8d6d5ad964b9e2372cd33da87c725bc/href">https://medium.com/media/b8d6d5ad964b9e2372cd33da87c725bc/href</a></iframe><p>SoundsViewController.swift <strong>audioPlayerDidFinishPlaying(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c3c3f3e77e0090d4a7974f2c78b1fff/href">https://medium.com/media/1c3c3f3e77e0090d4a7974f2c78b1fff/href</a></iframe><p>SoundsViewController.swift <strong>soundSaveButtonAction(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5955d98f510cb35a2539699a9f280a0a/href">https://medium.com/media/5955d98f510cb35a2539699a9f280a0a/href</a></iframe><p>SoundsViewController.swift <strong>Keyboard Control</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/531c6c41c2327e246befb90db70ff50f/href">https://medium.com/media/531c6c41c2327e246befb90db70ff50f/href</a></iframe><p>SoundsViewController.swift <strong>checkMicrophoneAccess()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13c024d6e92675651d39eddac2e5d6ea/href">https://medium.com/media/13c024d6e92675651d39eddac2e5d6ea/href</a></iframe><p>SoundsViewController.swift<strong> Save Check</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/383afd775a472f60695dffb7d516911c/href">https://medium.com/media/383afd775a472f60695dffb7d516911c/href</a></iframe><p>SoundsViewController.swift <strong>Helpers(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f220065422d9b74069b91ea8ac00fc5/href">https://medium.com/media/5f220065422d9b74069b91ea8ac00fc5/href</a></iframe><p>The article covered the complete setup, logic, and code to record, store, and play an audio file. We utilised <strong>AVFoundation</strong>, <strong>AVAudioRecorder</strong>, and <strong>AVAudioPlayer </strong>to record and play, and<strong> FileManager </strong>to store the audio file URL in the device. Then we linked the audio file URL to the specific ToDo Note in<strong> Core Data. </strong>Hope you find the article useful for your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af965bf92b26" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swift2go/swift-audio-record-store-and-play-af965bf92b26">Swift Audio: Record, Store, and Play</a> was originally published in <a href="https://medium.com/swift2go">Swift2Go</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift User Notifications: Authorise, Schedule, Monitor, and Remove.]]></title>
            <link>https://medium.com/geekculture/swift-user-notifications-authorise-schedule-monitor-and-remove-c6ff4ec808e5?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6ff4ec808e5</guid>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Wed, 16 Jun 2021 08:02:28 GMT</pubDate>
            <atom:updated>2021-06-16T08:02:28.850Z</atom:updated>
            <content:encoded><![CDATA[<p>Swift User Notifications Schedule a Notification Message to Appear, on the User Device, at a Specified Date and Time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9RzEFq8BP7rPZBWVvyIndQ.png" /><figcaption>AppsGym ToDo Remind Me User Notification</figcaption></figure><h3>Scenario</h3><p>Our ToDo app ‘<strong>Remind Me</strong>’ feature will schedule a User Notification to be triggered at the user-specified date and time. The app will also include an <strong>Active Notifications</strong> view, which shows all currently active ‘Remind Me’ notification requests, and a <strong>Cancel Notifications</strong> function in Settings.</p><h3>Technique</h3><p>We shall utilise Swift’s <strong>UserNotifications</strong> framework, to authorise, request, schedule, and (optionally) remove ‘Remind Me’ user notifications.</p><p>The <strong>AppDelegate.swift </strong>will contain the authorisation request of user notifications, so the pop-up alert will appear at the app first launch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*HiYkwLwgCB2jbu6yrCDcsw.png" /><figcaption>First App Launch Authorisation Request</figcaption></figure><p>The ToDo main view <strong>NoteViewController.swift</strong> will include the ‘<strong>Remind Me</strong>’ <strong>button</strong>, whose action, when tapped, will segue to a <strong>Date Picker </strong>view. The user will select the date and time, which will be passed back to the main view and stored as text in the ‘Remind Me’ <strong>text field</strong>. Upon saving the note record, we will check the User Notification authorisation status, and if authorised, then schedule the notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*5DPxhQkAM9nq5hj37Z4Ong.gif" /><figcaption>GIF Remind Me Date Picker and Notification Schedule</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to expedite their development projects.</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/todo-lists-notifications-multimedia/">ToDo</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8todo/id1375224765">8ToDo</a>), and you can download the complete <a href="https://appsgym.com/downloads/">Xcode</a> project on AppsGym.com, for free.</p><h3>User Interfaces</h3><p>On the Note view, we need a ‘<strong>Remind Me’ UIButton</strong>, which will segue to the Date Picker view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*c4QwlSvsPgKp7-CyXfkh2g.png" /><figcaption>Remind Me Button and Text Field</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*8scNQPp9X6ke1zF6wk5zrQ.png" /><figcaption>Remind Me Date Picker</figcaption></figure><p>We shall design a dedicated view for the <strong>Active Notifications</strong> monitoring, and add it in Queries (and maybe also Settings).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*i5WEI3XIAotIuJ362W31kQ.png" /><figcaption>AppsGym ToDo Active Notifications Query</figcaption></figure><p>We shall also design a dedicated view to<strong> Cancel Notifications</strong>, of all ToDo notes, and add it to the Settings menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*TUZaxzQQ0dHQ0z-d_BcsSA.png" /><figcaption>AppsGym ToDo Settings Cancel Notifications</figcaption></figure><h3>Logic</h3><p><strong>AppDelegate.swift</strong> will call the function <strong>authorizeUserNotifications()</strong>, which will request authorisation, triggering the initial app load pop-up (as setup in Info.plist).</p><p><strong>NoteViewController.swift, </strong>which handles new ToDo note addition and edit (update)<strong>, </strong>will call the:</p><blockquote><strong>checkUserNotification()</strong>, to check if user has authorised notifications.</blockquote><blockquote><strong>scheduleUserNotification()</strong>, to setup the Remind Me date/time notification.</blockquote><p>If the ToDo note is in Edit mode, then we remove any pending notifications for the note ID first, and then the Remind Me date/time is re-scheduled upon save.</p><p>An alternative arrangement is to include all user notification functions in their own dedicated <strong>UserNotifications.swift</strong> file, so they can be called from any other view.</p><p>The Queries <strong>ToDosByNotificationsTableViewController.swift</strong> will show all currently active user notifications.</p><p>The Settings <strong>CancelNotificationsViewController.swift </strong>will allow the user to cancel all pending and delivered user notifications.</p><h3>Code</h3><h3>AUTHORISE NOTIFICATIONS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*HiYkwLwgCB2jbu6yrCDcsw.png" /></figure><p><strong>AppDelegate.swift authorizeUserNotifications()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d074c24c3ddfd391f16f8799a9c2b177/href">https://medium.com/media/d074c24c3ddfd391f16f8799a9c2b177/href</a></iframe><h3>CHECK, REMOVE, and SCHEDULE NOTIFICATIONS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*c4QwlSvsPgKp7-CyXfkh2g.png" /></figure><p>NoteViewController.swift <strong>viewDidLoad()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/515d402f5459aca2fd8f932c83e07fd4/href">https://medium.com/media/515d402f5459aca2fd8f932c83e07fd4/href</a></iframe><p>NoteViewController.swift <strong>checkUserNotification()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36ef9d9511379925926e29cf74712916/href">https://medium.com/media/36ef9d9511379925926e29cf74712916/href</a></iframe><p>NoteViewController.swift <strong>saveRecordToCoreData()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6563444672cd276d2aed5ada0c4668f/href">https://medium.com/media/c6563444672cd276d2aed5ada0c4668f/href</a></iframe><p>NoteViewController.swift <strong>scheduleUserNotification()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4be879ce5592ae0014b60ab9b0dc6cf0/href">https://medium.com/media/4be879ce5592ae0014b60ab9b0dc6cf0/href</a></iframe><p>NoteViewController.swift <strong>Helper</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31ac5d054df5fdf51969624b61581498/href">https://medium.com/media/31ac5d054df5fdf51969624b61581498/href</a></iframe><h3><strong>MONITOR NOTIFICATIONS</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*i5WEI3XIAotIuJ362W31kQ.png" /></figure><p><strong>ToDosByNotificationsTableViewController.swift</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7afebe6d1292388cad5b7673ee6544e1/href">https://medium.com/media/7afebe6d1292388cad5b7673ee6544e1/href</a></iframe><h3><strong>CANCEL NOTIFICATIONS</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*TUZaxzQQ0dHQ0z-d_BcsSA.png" /></figure><p><strong>CancelNotificationsViewController.swift</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae758a79a3060c0742e95636b306c226/href">https://medium.com/media/ae758a79a3060c0742e95636b306c226/href</a></iframe><p>The article covered the complete setup, logic, and code to authorise, check, schedule, monitor, and remove user notifications. The comprehensiveness coverage of the subject scope necessitated a lengthy story, but we aimed for one place to cover the whole spectrum of Swift User Notifications activities.</p><p>Hope you find the content useful for your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6ff4ec808e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/swift-user-notifications-authorise-schedule-monitor-and-remove-c6ff4ec808e5">Swift User Notifications: Authorise, Schedule, Monitor, and Remove.</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Date/Time Periodic Repeats (Every Day, Week, Month, etc.)]]></title>
            <link>https://medium.com/swift2go/swift-date-time-periodic-repeats-every-day-week-month-etc-d2c0f4bf6b1?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2c0f4bf6b1</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[notifications]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Tue, 08 Jun 2021 06:46:38 GMT</pubDate>
            <atom:updated>2021-06-08T06:46:38.591Z</atom:updated>
            <content:encoded><![CDATA[<p>Period Repeats will Schedule a Repeat of an Event or Notification According to a User-Specified Frequency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*7KeMev0FYYJrBOVz2SXzpA.png" /><figcaption>AppsGym ToDo Remind Me Periodic Repeats</figcaption></figure><h3>Scenario</h3><p>Our app will schedule a repeating Remind Me date/time notification, based on a user-specified frequency. The user should be able to select a <strong>cycle</strong> value from 1 to 12, and an <strong>interval</strong> value (minutes, hours, days, weeks, months, and years).</p><h3>Technique</h3><p>We shall utilise Swift’s <strong>UIPickerView</strong> with 2 picker wheels: a <strong>Cycle</strong> <strong>wheel</strong> (from 1 to 12), and an <strong>Interval</strong> <strong>wheel</strong> (Minutes, Hours, Days, Weeks, Months, and Years). Each picker wheel moves independently from the other, giving the user maximum flexibility.</p><p>The Repeat Pickers View will implement a <strong>Delegate Protocol</strong>, with a function to return the user specified cycle and interval values back to the calling view. In our app, the ToDo Note view, which contains the Remind Me date/time field, will be the calling view. Hence, the ToDo Note view will act as the Repeat View Delegate and implement the Repeat View Delegate functions, which allows it to receive the selected cycle and interval picker values.</p><p>The logic to actually re-schedule the next reminder date/time is triggered when the user flags the current ToDo as done (completed).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*Su9_I1mTdlLMvTebdT7Q4A.gif" /><figcaption>GIF AppsGym ToDo Remind Me Repeat Setup</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects.</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/todo-lists-notifications-multimedia/">ToDo</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8todo/id1375224765">8ToDo</a>), and you can download the complete <a href="https://appsgym.com/downloads/">Xcode</a> project on AppsGym.com, for free.</p><h3>User Interfaces</h3><p>We need a <strong>Remind Me Repeat UIButton </strong>on the Todo Note view, which will navigate to the Repeat view. The Repeat view will show the <strong>Periodic</strong> <strong>UIPickerView</strong>, Cycle and Interval, and, when saved, return the values to the calling view. <em>Note</em>: There is only 1 UIPickerView, with 2 wheels, not 2 pickers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*d-vjPp4rm6_QwuxhAgWZ_g.png" /><figcaption>AppsGym ToDo Note View Showing the Remind Me and Repeat Table View Cells</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*_pTCVAY4tH-TP7366CC9Og.png" /><figcaption>AppsGym ToDo Repeat View</figcaption></figure><h3>Logic</h3><p><strong>NoteViewController.swift</strong> will contain a Repeat UIButton and a UITextField. The <strong>UIButton</strong> navigates to the RepeatViewController.swift, and the <strong>UITextField</strong> shows the current Periodic Repeat setup (‘Every 2 Days’, ‘Every 4 weeks’, ‘Every Month’, etc.). <em>Note</em>: the single interval has no numeric digits associated with it, hence ‘Every Month’, not ‘Every 1 Month’.</p><p>The UIButton triggers the <strong>“showRepeat” segue</strong> in the Storyboard, and passes the curent values of repeatCycles and repeatInterval. This allows the RepeatViewController.swift to show the current cycle and interval on the UIPickerView.</p><p>The NoteViewController acts as the RepeatViewControllerDelegate, linking the 2 views.</p><p>The <strong>RepeatViewController.swift </strong>implements the <strong>protocol</strong> <strong>RepeatViewControllerDelegate</strong> with its function repeatSelectiveOrPeriodic(..), as the same RepeatViewController also handles the (Date) Selective logic.</p><p>The RepeatViewController.swift initialised an array that contain the pre-defined cycles (1 to 12) and intervals (minutes, …, years), reflect the array values in the UIPickerView 2 wheels, and projects a text string of the current selections in a UILabel. It also contains a Save switch to save the user-selected values before returning to the calling view.</p><h3>Code</h3><p><strong><em>Note</em></strong>: The app RepeatViewController handles both Periodic (every …) and Selective (specific days of the week). In this article, the code snippets below the have been ‘trimmed’ to show only the Periodic part, allowing focus on article scope. A future article will focus on Selective repeats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*dMYK2dFHriDbanSwLWExAA.png" /><figcaption>NoteViewController.swift Showing Repeat Button and Label</figcaption></figure><p><strong>NoteViewController.swift: Initialise, Button Action, Delegate Methods</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df6fe9881c483ea5f39f5cfbc7475b32/href">https://medium.com/media/df6fe9881c483ea5f39f5cfbc7475b32/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*OFjuFrHZuEakrk6QvAxQDg.png" /><figcaption>RepeatViewController.swift</figcaption></figure><p><strong>RepeatViewController.swift </strong>Initialise Variables, Arrays, Buttons</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb1a26e7a2774e095fc1267a1e8491a1/href">https://medium.com/media/bb1a26e7a2774e095fc1267a1e8491a1/href</a></iframe><p>RepeatViewController.swift <strong>viewDidLoad()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86678b74e2b9eb010f0bc9f79b95c4b9/href">https://medium.com/media/86678b74e2b9eb010f0bc9f79b95c4b9/href</a></iframe><p>RepeatViewController.swift <strong>viewWillAppear() Show current wheel values</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0afbc0dfc7db63ea31ea87fbbab3c3e/href">https://medium.com/media/d0afbc0dfc7db63ea31ea87fbbab3c3e/href</a></iframe><p>RepeatViewController.swift <strong>pickerView Data Sources (from 2D Array)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3ce5d6a3a38423df14b944154bcb6d7/href">https://medium.com/media/c3ce5d6a3a38423df14b944154bcb6d7/href</a></iframe><p>RepeatViewController.swift <strong>pickerView Delegate Functions: Titles &amp; Selection Actions</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/548fbd3a7dd09538e125f7b870686230/href">https://medium.com/media/548fbd3a7dd09538e125f7b870686230/href</a></iframe><p>RepeatViewController.swift <strong>pickerView viewForRow(..) Colour Wheels</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/229f277023bbc7a93ef6279966d146fe/href">https://medium.com/media/229f277023bbc7a93ef6279966d146fe/href</a></iframe><p>RepeatViewController.swift <strong>updatePeriodicLabel() Reflect wheel values</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d707ca71478a943cbe81f8e9363e162d/href">https://medium.com/media/d707ca71478a943cbe81f8e9363e162d/href</a></iframe><p>RepeatViewController.swift <strong>willMove(..) Return to Calling View</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c6c095d1723e49139c78d68b44151db/href">https://medium.com/media/6c6c095d1723e49139c78d68b44151db/href</a></iframe><p>The article covered the complete setup, logic, and code to implement a comprehensive date/time periodic repeat feature. The repeat frequency consisted of cycles (1 to 12) and intervals (minutes, days, .., years) and utilised Swift’s UIPickerView with 2 wheels. Hope you find the article useful for your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2c0f4bf6b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swift2go/swift-date-time-periodic-repeats-every-day-week-month-etc-d2c0f4bf6b1">Swift Date/Time Periodic Repeats (Every Day, Week, Month, etc.)</a> was originally published in <a href="https://medium.com/swift2go">Swift2Go</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift 5-Star Rating System of Core Data Records]]></title>
            <link>https://mazenkilani.medium.com/swift-user-rating-stars-for-app-records-dd56507281ec?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd56507281ec</guid>
            <category><![CDATA[swfit]]></category>
            <category><![CDATA[rating-system]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Sun, 06 Jun 2021 01:34:03 GMT</pubDate>
            <atom:updated>2021-06-10T23:30:41.709Z</atom:updated>
            <content:encoded><![CDATA[<p>Users Rate App Records by a 5-Star Rating System</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*6BQ4zKNXLbSbjuU9LsSRJQ.png" /><figcaption>AppsGym Books Rating Stars</figcaption></figure><h3>Scenario</h3><p>Our app allows users to rate the records (books) using a similar setup to Amazon’s 5-star rating system. Each of the stars can either be empty (grey star) or filled (yellow star). The user can</p><blockquote><strong>Do nothing</strong>, leaving the 5 stars empty</blockquote><blockquote><strong>Assign Rating Stars</strong>, from 1 to 5 (the number of filled yellow stars)</blockquote><blockquote><strong>Clear the Rating Stars</strong>, if the user changes their mind after assigning stars</blockquote><p>This article will replicate Amazon’s rating style (0, 1 to 5 stars), as our practical example is related to books. However, the app entities can be cafés, recipes, or any other entity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*D3hlDs4lET7R5B3NdMR_RQ.gif" /><figcaption>GIF Book Rating Stars in New Book and Book Detail Views</figcaption></figure><h3>Technique</h3><p>The star <strong>visual</strong> representation and interactivity (user can tap any star) will need a button <strong>@IBOutlet</strong> for each star (1 to 5), as well as a button to clear all stars (0 stars). The actual ‘rating’ value will be a <strong>text</strong>, e.g., “0Stars”, “1Star”, “5Stars” (naturally, you can choose to use a numeric value: 0 to 5). Each rating star will have 2 associated <strong>images</strong>: Star_Empty (blank star) and Star_Solid (yellow star).</p><p>Each of the 6 star-buttons will have a unique <strong>Tag</strong> (0 to 5). All the star buttons will be linked to one<strong>@IBAction</strong>, with a Switch statement on the button <em>tag</em>. The tag corresponding case turns each star ON (image Star_Solid yellow) or OFF (image Star_Empty).</p><blockquote><strong><em>Note</em></strong>: If the user taps any star, then the tapped star <em>and all the stars before i</em>t will turn ON (image Star_Solid ) and <em>all the stars after it</em> will turn OFF (image Star_Empty). If the user taps the Clear Stars, the app turns all stars OFF.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*7MWgyAYPZVo2YwRXtBajlA.png" /><figcaption>User Taps the 3rd Star: 1–3 On, 4 and 5 Off</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects. The code snippets below can be used with minimal customisation.</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/projects/books/">Books</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8books/id1152860892">8Books</a>), and you can download the complete <a href="https://appsgym.com/appsgym-books-swift-xcode-project-tour/">Xcode project</a> on <a href="https://appsgym.com/">AppsGym.com</a>, for free.</p><h3>User Interface</h3><p>The <strong>NewBookTableViewController </strong>and<strong> the BookDetailsViewController </strong>share the same, but not identical, visual representation of the Rating Stars:</p><p><strong>New Book</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*2W80RMCNEz0p37scgpt3pw.png" /><figcaption>New Book Storyboard</figcaption></figure><p><strong>Book Details</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*TcWactU_5wjAsoDeyJlBZQ.png" /><figcaption>Book Details Storyboard</figcaption></figure><h3>Logic</h3><p><strong>NewBookTableViewController.swift </strong>&amp;<strong> BookDetailsViewController.swift </strong>will have 6 @IBOutlets, 1 var <em>rating</em> (String) and 1 @IBAction func <em>ratingSelected(..)</em>, with a <strong><em>switch</em></strong> statement based on the <strong><em>sender.tag</em></strong><em> </em>(the UIButton and its tag value).</p><p>The <strong>NewBookTableViewController </strong>will display all stars empty. The <strong>BookDetailsViewController </strong>will display the stars as per current rating in the Core Data record. In both cases, the logic is the same afterwards: the user can tap/touch any star to indicate their chosen rating or clear all stars.</p><p><em>Note</em>: You may like to evaluate alternative ways to display and execute the 5- stars system (e.g., touchesBegan location, Gesture Recogniser location), and you can also employ different code techniques (e.g., array of buttons, for 0…5 loops). Our choice for this article, a bit manual and repetitive in setup, is chosen for its simplicity and ease of implementation.</p><h3>Code</h3><h3>Code: <strong>NewBookTableViewController.swift</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fca5d28df7533d9aeb75adb2326291a/href">https://medium.com/media/0fca5d28df7533d9aeb75adb2326291a/href</a></iframe><p>NewBookTableViewController.swift <strong>ratingSelected(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94ab0e0fc7de460afc8415520f2bf9b1/href">https://medium.com/media/94ab0e0fc7de460afc8415520f2bf9b1/href</a></iframe><h3>Code: <strong>BookDetailsViewController.swift</strong></h3><p>BookDetailsViewController.swift <strong>Initialise and viewDidLoad()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de9aeea1cc4ae73c41a03861fbc2d09e/href">https://medium.com/media/de9aeea1cc4ae73c41a03861fbc2d09e/href</a></iframe><p>BookDetailsViewController.swift<strong> ratingSelected(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61cc52cba2f6253a74554c273931857d/href">https://medium.com/media/61cc52cba2f6253a74554c273931857d/href</a></iframe><p>BookDetailsViewController.swift <strong>setRatingStars(..)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/039ffa16dfd68aca2a9a4308de3777cf/href">https://medium.com/media/039ffa16dfd68aca2a9a4308de3777cf/href</a></iframe><p>The article covered the implementation of a user rating stars system in our model Books app. Any book can have a 1 to 5 stars rating, or none. The user can set up the rating upon adding a new book, or later in the book details view. Naturally, the rating stars system can be applied to any app entities (cafés, recipes, photos, etc.). Hope you find it useful in your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd56507281ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift UITableView Swipe Actions]]></title>
            <link>https://mazenkilani.medium.com/swift-uitableview-swipe-actions-4c1069d5717c?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c1069d5717c</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[uitableview]]></category>
            <category><![CDATA[swipe]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Thu, 03 Jun 2021 01:02:42 GMT</pubDate>
            <atom:updated>2021-06-10T23:35:09.690Z</atom:updated>
            <content:encoded><![CDATA[<p>UITableView Leading and Trailing Swipe Menu Actions Allow Users to Either Apply Actions on Displayed Records or Navigate to a New View.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*pva-iaOKf0JGAGswszUCuA.png" /><figcaption>AppsGym Books Table View Showing Leading and Trailing Swipe Gesture Menus</figcaption></figure><h3>Scenario</h3><p>Our app allows leading and trailing swipe gesture menu actions on the Books table view. The <strong>Leading</strong> actions will update a Core Data record field value in-place (within the table view). The <strong>Trailing</strong> actions will delete (in-place), edit (sequence to another view) or share (in-pace) a table row record.</p><h3>Technique</h3><p>We shall utilise Swif’s swipe action functions:</p><p><strong>leadingSwipeActionsConfigurationForRowAt(),</strong> which controls the swipe right to left</p><p><strong>trailingSwipeActionsConfigurationForRowAt(..)</strong>, which controls the swipe left to right</p><p>where we define the menu options and corresponding actions (configuration) for each swipe gesture.</p><p><strong><em>Note</em></strong>: iOS 15 SwiftUI introduced a new modifier called .swipeActions for developers to create custom swipe actions in any list rows, using .swipeActions(edge: .leading) and .swipeActions(edge: .trailing).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*cFCzA9Bjx7JwKNu4wE6_gQ.gif" /><figcaption>GIF AppsGym Books UITableView Swipe Actions</figcaption></figure><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects.</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/projects/books">Books</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8books/id1152860892">8Books</a>), and you can download the complete <a href="https://appsgym.com/appsgym-books-swift-xcode-project-tour/">Xcode</a> project on <a href="https://appsgym.com/">AppsGym.com</a>, for free.</p><h3>User Interfaces</h3><p>There are no specific UI setup needed, as the UITableView display logic and code will show the complete set of Core Data records. The swipe action functions will show the icons (and/or text) of the actions and execute the associated logic code.</p><p>In our example, the <strong>Leading</strong> swipe action will change the Book <strong><em>Upload</em></strong> status, as a toggle switch, using images to show the current status. So, we need to prepare 2 images: Uploaded and NotUploaded, check the current upload status and show the relevant image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*lH_-0VJpLQb-7PwqAjbzUg.png" /><figcaption>AppsGym Books Table Row Showing Cloud Upload Status</figcaption></figure><p>The Trailing <strong><em>Share</em></strong> swipe action will launch the device native Share menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*K76Ta8KJ8e5h26aml8dBow.gif" /><figcaption>GIF AppsGym Books Trailing Swipe Share Action</figcaption></figure><h3>Logic</h3><p><strong>BooksTableViewController.swift</strong> show the app Core Data records. It will also implement the swipe actions.</p><p><strong>leadingSwipeActionsConfigurationForRowAt() </strong>will allow the user to change the book <strong>upload</strong> status, in a toggle switch manner. If the current status shows as Uploaded, then the action will change it to NotUploaded.</p><p><strong>trailingSwipeActionsConfigurationForRowAt() </strong>will allow the user to:</p><ol><li><strong>Delete</strong> the book record, in-place in the table view, and its associated photos/images</li><li><strong>Edit</strong> the book record, navigating to the Edit Book view</li><li><strong>Share</strong> the book record, showing the native Share menu of the device</li></ol><h3>Code</h3><h4><strong>BooksTableViewController.swift</strong></h4><h3><strong>leadingSwipeActionsConfigurationForRowAt</strong>(..)</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4678365a528fb3373b3235763be49c5/href">https://medium.com/media/f4678365a528fb3373b3235763be49c5/href</a></iframe><h4>swipeUploadedFlagAction(..)</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/440c51d39c4952ef0b61c106376ec284/href">https://medium.com/media/440c51d39c4952ef0b61c106376ec284/href</a></iframe><h3><strong>trailingSwipeActionsConfigurationForRowAt</strong>(..)</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa5c6c22ff707d00c6f183ae37910e7a/href">https://medium.com/media/aa5c6c22ff707d00c6f183ae37910e7a/href</a></iframe><h4>swipeDeleteAction(..)</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebbf00e2e297090b77865327afcf979e/href">https://medium.com/media/ebbf00e2e297090b77865327afcf979e/href</a></iframe><h4>swipeShareAction(..)</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6b51db89d5d25f734185696b724d649/href">https://medium.com/media/b6b51db89d5d25f734185696b724d649/href</a></iframe><p>The article covered the complete setup, logic, and code to implement UITableView leading (left to right) and trailing (right to left) swipe gesture actions. We examined the cases of:</p><ol><li>Update a Core Data record field value in-place (within the table view), in the Upload Flag action</li><li>Delete a Core Data record (from the database, table view and array) and its associated photos, accessing 2 separate Core Data entities</li><li>Navigate via segue to another view, in the Edit action</li><li>Share the table record data, using the device native share menu pop-up</li></ol><p>Hope you find it useful in your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c1069d5717c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Text To Speech Synthesizer]]></title>
            <link>https://medium.com/geekculture/swift-text-to-speech-synthesizer-ddf4e16f3fc6?source=rss-fbfa6ba21b5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddf4e16f3fc6</guid>
            <category><![CDATA[synthesizers]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Mazen Kilani]]></dc:creator>
            <pubDate>Sun, 30 May 2021 22:58:23 GMT</pubDate>
            <atom:updated>2021-06-01T06:39:11.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*gpyPoPCgEzsEDzrdX0jGQg.png" /><figcaption>AppsGym Books App Ms. Chips Reading the Book Synopsis</figcaption></figure><p><strong>Swift’s Text to Speech Synthesizer Can Speak Aloud the Contents of Text Fields and Views.</strong></p><h3>Scenario</h3><p>Our app will utilise a text to speech synthesizer (also, synthesiser), which we shall affectionately call <strong>Ms. Chips</strong>, in the Book Details view. Ms Chips will read aloud the text of the <strong>Synopsis</strong> field.</p><h3>Technique</h3><p>We shall utilise Swift’s <strong>AVSpeechSynthesizerDelegate</strong> functions, where the BookDetailsViewController, which contains the Synopsis field and Ms. Chips robot button, acts as the delegate.</p><h3>Audience</h3><p>The article is for Swift developers who seek complete, proven, code-centric solutions to speed up their development projects. The code snippets below can be used with minimal customisation (your app designated UITextView).</p><h3>App Model</h3><p>We based the article on the AppsGym <a href="https://appsgym.com/projects/books">Books</a> model app, published on Apple’s App Store (as <a href="https://apps.apple.com/au/app/8books/id1152860892">8Books</a>), and you can download the complete <a href="https://appsgym.com/appsgym-books-swift-xcode-project-tour/">Xcode</a> project on <a href="https://appsgym.com/">AppsGym.com</a>, for free.</p><h3>User Interfaces</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/76/1*udtVhIVuGZ1jhynJoaF_OA.png" /><figcaption>Ms. Chips, AppsGym Books Robot Synthesizer Default Icon</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/83/1*Fo1WJ19IuBowCoSIbeYn_w.png" /><figcaption>Ms. Chips, AppsGym Books Robot Synthesizer While Speaking Icon</figcaption></figure><p>The UI is an icon button of Ms. Chips, with a toggle switch. Tap once to start speaking and tap again to stop.</p><h3>Logic</h3><p><strong>BookDetailsViewController.swift</strong> controls the start/stop of Ms. Chips synthesizer. The BookDetailsViewController acts as a <strong>delegate</strong> to <strong>AVSpeechSynthesizer</strong>, hence implements the required delegate functions.</p><p>Our charming robot, Ms. Chips, will be represented by a button on the Book Details view, which acts as a toggle on/off switch. Tap once to start, tap again to stop. Hence, we need the following functions: <strong>didStart </strong>utterance: AVSpeechUtterance and <strong>didFinish </strong>utterance: AVSpeechUtterance. We shall also change the button icon image to indicate the status (slient or speaking).</p><p>In addition, Ms. Chips should stop reading aloud if the user dismisses the view. Hence, we need the <strong>viewDidDisappear</strong>() to stop the synthesizer robot speaking.</p><h3><strong>Code</strong></h3><p>BookDetailsViewController.swift <strong>viewDidLoad()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9215d3f74148e21cb9666e57378ee96a/href">https://medium.com/media/9215d3f74148e21cb9666e57378ee96a/href</a></iframe><p>BookDetailsViewController.swift <strong>robotButtonAction()</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/201af485003145b96bdb7ffa43d2397e/href">https://medium.com/media/201af485003145b96bdb7ffa43d2397e/href</a></iframe><p>BookDetailsViewController.swift <strong>Synthesizer Delegate Functions</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90c8d991087b3e4d6c6049e8d1f4d9d6/href">https://medium.com/media/90c8d991087b3e4d6c6049e8d1f4d9d6/href</a></iframe><h3><strong>Too Easy for You?</strong></h3><p>We can make our synthesizer more interesting by utilising Swift’s methods to control <strong>Rate</strong>, <strong>Pitch</strong> and <strong>Volume</strong>. Then we change <strong>Voice</strong>, with different dialects and languages. You can research and update your app now, but we shall publish a dedicated article at a later date. Stay tuned!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*DxyDvTGS9y4SWMsHS3Xe6g.png" /></figure><p>The article covered the complete setup and code to implement a ‘quick and easy’ text to speech synthesizer, in the Book Details view. The synthesizer will read aloud the text of the book Synopsis UITextView. Hope you find it useful in your app. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddf4e16f3fc6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/swift-text-to-speech-synthesizer-ddf4e16f3fc6">Swift Text To Speech Synthesizer</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>