<?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 Damien Laughton on Medium]]></title>
        <description><![CDATA[Stories by Damien Laughton on Medium]]></description>
        <link>https://medium.com/@dfplaughton?source=rss-e9bb96b29f78------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Dp-3DAo1GEameSiO.</url>
            <title>Stories by Damien Laughton on Medium</title>
            <link>https://medium.com/@dfplaughton?source=rss-e9bb96b29f78------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 13 Jul 2026 10:30:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dfplaughton/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[UITextField Obscura]]></title>
            <link>https://medium.com/@dfplaughton/uitextfield-obscura-9e155c6d6a3d?source=rss-e9bb96b29f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e155c6d6a3d</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[uitextfield]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[keyboard]]></category>
            <category><![CDATA[constraints]]></category>
            <dc:creator><![CDATA[Damien Laughton]]></dc:creator>
            <pubDate>Sun, 19 May 2019 15:21:11 GMT</pubDate>
            <atom:updated>2019-05-19T15:21:11.283Z</atom:updated>
            <content:encoded><![CDATA[<p>How to have UITextfields and never have them obscured.</p><p>or</p><p>How to make a basic interface perform really well.</p><h3>Problem</h3><p>From time to time as a developer working on an iOS project you might see a ticket of work like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*Rd26QLmKaN9LV3Pv7uiblg.png" /><figcaption><em>That same old bug</em></figcaption></figure><p>I see this ticket in many iOS projects and the reason it ever exists in my opinion is that behaviour of interfaces is often not specified and therefore a developer can think that their job is done when it actually isn’t.</p><p>Here is a video of the problematic behaviour:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FhOYRdCFdKac%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DhOYRdCFdKac&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FhOYRdCFdKac%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7eb63d74f39789506ca1e89fe4c3a15/href">https://medium.com/media/b7eb63d74f39789506ca1e89fe4c3a15/href</a></iframe><p>There is a repository for this post and here is a link <a href="https://github.com/damienlaughton/uitextfieldobscura/tree/problem">here</a>. If you select the branch ‘<em>problem’</em> you can see the issue above.</p><p>Let’s fix that ticket!</p><h3>Goals</h3><ol><li>Zero changes the layout (UI)</li><li>Keep any information on the view available to the user at any time.</li></ol><p>We will do this by making the view scrollable so that as soon as the user taps on a UITextfield the view moves up above the keyboard and if the user wishes to scroll the view to see content that is now off screen they can do so.</p><h3>Solution</h3><p><strong>Step 1: </strong>The storyboard doesn’t have a UIScrollview in it so the first thing we need to do is get the current content into a scrollview.</p><p>This is easiest achieved by first putting all the components of the view into a separate UIView which will become the content view of the scrollview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y1U8wBoXiT_zeOvy5O2NvA.png" /><figcaption>Xcode → Editor → Embed In → View</figcaption></figure><p>The new view will be our content view so let’s call it that in the storyboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*ma7AtFd8krJsNfxZBG13AQ.png" /><figcaption>Name the parts of the UI appropriately</figcaption></figure><p>Notice that we have broken a ton of constraints and now Xcode is highlighting the broken and missing constraints in red. We will fix these issues shortly.</p><p><strong>Step 2</strong>: Now embed our content view inside a scroll view. This time it’s fine to leave the naming to Xcode as it uses ‘Scroll View’ automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVpN2lrdQbCgluvwpEmN6g.png" /><figcaption>After Xcode → Editor → Embed In → Scroll View</figcaption></figure><p><strong>Step 3</strong>: Fix those broken constraints.</p><p>First make sure that the components of the content view fit correctly as desired within the content view. Then:-</p><p><strong>This is the important bit</strong></p><p>The scroll view should be pinned to it’s superview which is pinned to the Safe Area.</p><p>The content view of the scroll view should also be pinned to the superview of the scroll view (in our project this is the main view).</p><p><strong>Why are we doing this?</strong></p><p>Let’s remind ourselves how a scroll view works. If the content of a scrollview is the same dimension (or less) than that of the scroll view itself then the scroll view does not scroll.</p><p>For the scroll view to scroll the content of the scroll view must be of a greater dimension that the scroll view itself. We will take advantage of this behaviour to achieve our desired behaviour by adjusting the position of the bottom of the scrollview when the keyboard is on screen. Doing so will make the content of the scroll view greater than the height of the scroll view <em>and it will become scrollable</em>.</p><p>One last adjustment before we recap the constraints. Reduce the priority of the content view height to 250. This will mean that the height constraint of the content will be lower than the constraint pinning the content to the bottom of the scroll view. This is essentially the magic.</p><p><strong>Recap</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNHzU8Wz8fjMjMc9UDQ-CA.png" /><figcaption>Content view constraints</figcaption></figure><p>We can test that the magic will work. Temporarily change the background colour of the main view to a light grey and then adjust the constant of the constraint which pins the scroll view to main view. I changed it to 100 and this is what should happen in your storyboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9KBw_n0mQhUVQl8RwD3vxA.png" /><figcaption>Scroll view constant adjusted</figcaption></figure><p>Step 4: Now we need to stitch together our storyboard work with some code.</p><p>Instead of working in the ViewController class lets create a BaseViewController which can act as our super class for the ViewController and keep all of this code which once working we can then forget about and better still not have it cluttering up our ViewControllers which need to be concerned with other work.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58afe1d86a7d9d9863d45611f2ad0f0b/href">https://medium.com/media/58afe1d86a7d9d9863d45611f2ad0f0b/href</a></iframe><p><strong>Step 5</strong>: @IBOutlet</p><p>Lastly dont forget that there is now an @IBOutlet which needs to be linked up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-q2tEDbDuN3hYhS8R7gO2Q.png" /><figcaption>Connect the @IBOutlet</figcaption></figure><p><strong>Recap</strong>:</p><p>The new super class BaseViewController adds behaviour in three ways.</p><ol><li>Firstly it observes two cocoa touch events</li></ol><p>UIResponder.keyboardWillShowNotification<br>UIResponder.keyboardWillHideNotification</p><p>When those events occur we know it’s time to adjust the constraint on the bottom of the scroll view.</p><p>2. Secondly it adds a tap gesture to the view so that the screen will be reset when after the user taps away from a text field.</p><p>3. When the ‘Return’ key on a UITextField is tapped the screen will be reset.</p><h3>Results</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FEFXyMQGlPGY%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEFXyMQGlPGY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FEFXyMQGlPGY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/084e20b3834ee1256cff9ce005f88c75/href">https://medium.com/media/084e20b3834ee1256cff9ce005f88c75/href</a></iframe><h3>Code</h3><p>Finally <a href="https://github.com/damienlaughton/uitextfieldobscura/tree/solution">here</a> is the link to the solution code.</p><p>Thank you for reading to the end</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e155c6d6a3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When tickets go bad]]></title>
            <link>https://medium.com/@dfplaughton/when-tickets-go-bad-9560cc211697?source=rss-e9bb96b29f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/9560cc211697</guid>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[sprint]]></category>
            <category><![CDATA[tickets]]></category>
            <category><![CDATA[scrum]]></category>
            <category><![CDATA[teamwork]]></category>
            <dc:creator><![CDATA[Damien Laughton]]></dc:creator>
            <pubDate>Tue, 18 Sep 2018 14:49:37 GMT</pubDate>
            <atom:updated>2018-09-18T16:10:31.252Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*64X4Z6357BYw_NnsbuCyQQ.jpeg" /><figcaption>Bieber Ticket</figcaption></figure><p>or</p><h3><strong><em>Ticket discipline starts in elaboration.</em></strong></h3><p>When we work in an agile environment we can expect to be given work in ticket form. The ticket is one of the glues of the agile environment, so it follows that good tickets promote a good working environment and bad tickets …</p><p><em>don’t</em>.</p><p><strong>What happens when there is a bad ticket?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*ljloBVlApbz-8OY_PUKbQw.jpeg" /><figcaption>Sky falls in</figcaption></figure><p>A ticket can be bad in many ways but when it <em>is</em> bad then it’s guaranteed that:</p><ol><li>Developers wont know what needs to be developed.</li><li>Quality Assurance will find recognising quality especially difficult.</li><li>Managers wont know what’s being done and when.</li><li>Managers wont recognise when there are genuine blockers ahead.</li></ol><p>In short: <strong><em>When there are bad tickets, bad things happen.</em></strong></p><p><strong>What makes a ticket bad</strong>?</p><p>🛑Size: If your team looks at a ticket and assigns it 13 points, or 8 points. Odds on, that ticket is simply too big to handle. Sure, some things in life are complicated and the complexity needs to be recognised however if we assert that a team member only has a fixed capacity of points each sprint it’s easy to see that large tickets will take up large amounts of that capacity. Having a team member spend half of a sprint on one ticket is too much; reason:</p><p>There will be dependencies on tickets and there will blockers on tickets, so to minimise the impact of dependencies and blockers we need to make tickets small.</p><p><strong><em>Small tickets are maneagable tickets</em></strong><em>.</em></p><p>🛑Duplicates: This is obvious right? No-one would create a duplicate ticket deliberately, but, what if two tickets are ‘almost’ duplicates of one another? What if your team are creating a sprint board that resembles a Venn diagram of tickets? If you look at the sprint board and see five tickets that all overlap one another then you are in for a painful ride.</p><p><strong>Tickets need to be visibly distinct from one another</strong></p><p>If you find that that tickets are literally bouncing of people’s eyeballs without them noticing or understanding the contents of the ticket then it’s a certainty that your tickets are not distinct <em>enough</em> from one another.</p><p>Several bad things can happen at this point, not least that the wrong work gets done on a ticket but also that team members stop looking at tickets as single pieces of work.</p><p>Instead they pick up two or three tickets simultaneously and work on all the tickets at the same time:</p><p>You need to recognise that, when a team member picks up 26 points of work in one go, then it’s an immediate red flag!</p><p><strong>If it’s more effort to pick tickets apart than it is to attempt all the tickets at once then you have created Venn Diagram tickets.</strong></p><p>🛑Incomplete: You’re sat in the elaboration meeting and everything is crystal clear. Everyone present understands the task and everyone agrees that the text on the ticket acurately describes the task in hand.</p><p>Later, may be near the end of sprint the ticket is picked up. It’s at this point that it becomes apparent that not everything that was known at the time of elaboration, is explained on the ticket. Something, maybe several things have been omitted from the ticket and what once made sense, now makes no sense.</p><p>We all know about ‘ticket discipline’ which is, “When I pick up a ticket, what do I need to do?” but after reflecting on all of the above, to me it seems that:</p><p><strong><em>Ticket discipline starts during elaboration.</em></strong></p><p>&amp;</p><p><strong><em>Ticket discipline is a team discipline.</em></strong></p><p>During elaboration, it’s the teams job to make good tickets.</p><p><strong>Tickets need to be:</strong></p><p>✅Small - so they are maneagable.</p><p>✅Distinct - so they cannot be confused with other tickets.</p><p>✅Complete - so everything you need to know is right there on the ticket.</p><p>Thanks for reading this far. Why not give me a clap and / or leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9560cc211697" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS Springboard Security [Revisited]]]></title>
            <link>https://medium.com/@dfplaughton/ios-springboard-security-revisited-f55d7f057e4a?source=rss-e9bb96b29f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/f55d7f057e4a</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Damien Laughton]]></dc:creator>
            <pubDate>Fri, 27 Apr 2018 13:13:36 GMT</pubDate>
            <atom:updated>2018-04-27T13:13:36.032Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*o1X-M5bBFu0379NAEZISVg.jpeg" /><figcaption>An image we’ve all seen before . . . of a springboard!</figcaption></figure><p>The Springboard or app switcher is the UI/UX interface in iOS for switching between applications. It’s great but sometimes as developers of apps, we forget that the iOS is evolving with each release and some behavioural changes can trip us up.</p><p>Recently, a tester working on an app with me pointed out that it’s posible to see sensitive [payment] information on the app while it is in the springboard. This shouldn’t happen and the app had previously employed a [working] technique to obscure this information. Something had “broken”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*QdJ9MJENb6VlKAGNLorQaQ.png" /><figcaption>An app — helpfully displaying confidential information while in the Springboard.</figcaption></figure><p>So, how often do you check that your security features are still working as expected?</p><p>Do you do it every time a new iOS is released?<br>Every time a new iOS minor release is available?<br>How about every time you release a version of your app?<br>Bro, do you even regression test?</p><p><strong>What just happened?</strong></p><p>The technique employed to mask sensitive application is a common one.</p><ol><li>When the app is resigning active</li><li>Load an image</li><li>Display it over the window</li></ol><p>I looked at the code in <strong><em>applicationWillResignActive</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*Z5lcHk8JSnvMnoqXLSpxMw.png" /><figcaption>Pretty standard stuff</figcaption></figure><p>Pretty standard stuff; I checked and it was still getting called so what the … ?</p><p><strong>Test, test a lot. No, more than that…</strong></p><p>So, we tested a bunch more, we tested … a lot. It turned out that if we single pressed the home button the app would always behave and show the lock screen. But if we double pressed the home button (go straight to Springboard) the app pretty much always failed to show the lock screen. this kind of behaviour happened on all our test devices, iPad or iPhone which was a real big surprise.</p><p><strong>Timing</strong></p><p>Turns out that loading an image with <strong><em>UIImage.named</em></strong> takes time and it takes more time than modern iOS was willing to supply when resigning active and heading straight to the Springboard. This security feature did work originally but at some point Apple introduced double press the Home button which in our testing always gave the app less time to clean up.</p><p>In addition, the Springboard is a major feature in iOS so it is liable to change under the hood with every release from Apple.</p><p><strong>Our Fix</strong></p><p>Take less time. Thankfully it was pretty straightforward to do this.</p><ol><li>Ensure the image and image view you are going to use are ready and loaded into memory before you need them in <strong><em>applicationWillResignActive</em></strong>. At this point our project started to behave but we chose in addition to use a smaller image to make an incremental saving in speed.</li><li>Dont use a massive image. The original image used in this project was 2.4MB which we reduced to 250k. At this point we were all pretty happy with the performance but it is possible to do something more if neccessary.</li><li>If you really want to make sure your app has enough time, don’t even use an image, just add a [black] view over the window.</li></ol><p>Once we reduced the time it takes to obscure the app things started to look a lot rosier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*3w_QDQwtgiOPLNAcXCMcRw.png" /><figcaption>Yay! A working Lock Screen.</figcaption></figure><p><strong>Summary</strong></p><p>Dont assume that something that once worked is going to continue working forever.</p><p>Do test.</p><p>Test more than that.</p><p>________</p><p><a href="https://github.com/damienlaughton/SensitiveInformation">Here</a> is a github project with a working implementation of a lock screen. Feel free to have a look and use it if you want.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f55d7f057e4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kerning — pardon?]]></title>
            <link>https://medium.com/@dfplaughton/kerning-pardon-93dbe1b5d366?source=rss-e9bb96b29f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/93dbe1b5d366</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[typography]]></category>
            <dc:creator><![CDATA[Damien Laughton]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 13:14:24 GMT</pubDate>
            <atom:updated>2018-04-06T13:14:24.594Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Designer</em>: Can you have a look at the fonts on the login screen? The kerning doesn’t match the designs I gave you.</p><p><em>Developer</em>: WhatTheWhat is Kerning?</p><p>There was a time when such conversations could lead to …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*O9C_PDSETOtbgiR69fCUPA.png" /><figcaption>Kerning Examples — courtesy Wikipedia</figcaption></figure><p><a href="https://en.wikipedia.org/wiki/Kerning"><em>Kerning</em></a><em> is the typographical adjustment of the space between character glyphs.</em></p><p>That sounds quite complex and guess what it can be. In the WAR image above the top line has no kerning, the middle line has ‘automatic’ kerning and the bottom line has ‘manual’ kerning; which means some glyphs are kern(ed) more than others.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FLAFShX32UwUj6%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fsigh-disappointed-LAFShX32UwUj6&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FLAFShX32UwUj6%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="374" frameborder="0" scrolling="no"><a href="https://medium.com/media/88af06ac8a830352a6c54958b6a3a8ef/href">https://medium.com/media/88af06ac8a830352a6c54958b6a3a8ef/href</a></iframe><p>Luckily, most of the time in app development (maybe in IT development?) when the designer mentions kerning, they probably mean tracking.</p><p><a href="https://en.wikipedia.org/wiki/Letter-spacing"><em>Tracking</em></a><em> is a consistent spacing between a series of letters.</em></p><p><strong>Confused?</strong></p><p>In iOS with the introduction of the Attributed String we as developers can configure strings of text to easily achieve tracking and if a string really needs kerning we can do that too with a little more effort. Confusingly there is only one attribute to modify on an attributed string to achieve either kerning or tracking and that is:</p><p><strong>NSAttributedStringKey.kern</strong></p><p>Essentially, if you kern the whole of a string consistently then that is <strong>tracking</strong>; if you dig deep and kern different parts of the same string with different values for spacing then that is <strong>kerning</strong>.</p><p><strong>UIKerningTextField</strong></p><p>Repeat readers of my posts will recognise my affinity with customising UITextField. I’ve done it again! UIKerningTextField allows you to achieve tracking. Should it be called UITrackingTextField? Possibly. Here it is in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*T6JSkLLUet8y7LAEkVP71Q.png" /><figcaption>UIKerningTextField in action.</figcaption></figure><p>The top text field has no kerning applied. The middle text field has a -ve value applied, which draws the letters together. The bottom text field has a +ve kerning value which spaces the characters further apart.</p><p><a href="https://gist.github.com/damienlaughton/f75a72c42f465b42e71891e6f643a6bb">Here</a> is a gist for UIKerningTextField. As always, I reserve no rights to the techniques / code; just use as you will.</p><p><strong>Footnote</strong></p><p>If you really need to achieve kerning and not just tracking then you need to do more work and that exercise I leave to you dear reader…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93dbe1b5d366" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NSManagedObject + Auto Date Stamping]]></title>
            <link>https://medium.com/@dfplaughton/nsmanagedobject-auto-date-stamping-cd5f0dec392b?source=rss-e9bb96b29f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd5f0dec392b</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[core-data]]></category>
            <dc:creator><![CDATA[Damien Laughton]]></dc:creator>
            <pubDate>Mon, 02 Apr 2018 14:02:25 GMT</pubDate>
            <atom:updated>2018-04-03T08:03:00.800Z</atom:updated>
            <content:encoded><![CDATA[<p>CoreData can seem something of a mystery but there are many techniques and 3rd party libraries available to make life more bearable while at the same time getting downright dirty with the power available in CoreData.</p><p><strong>C</strong>reate <strong>R</strong>ead <strong>U</strong>pdate <strong>D</strong>elete</p><p>Databases are essentially CRUD systems and when we as developers use them it’s a really good idea to know when a record in the database was created and when it was last updated.</p><p><strong>Date Stamping</strong></p><p>Say we have a member variable of a NSManagedObject, <strong>date_created</strong> and another member variable <strong>date_modified.</strong> We could, each time we change the object, also remember to change these two member variables accordingly.</p><p>This is nice and well meaning but each time we wish to update those variables we have to know, “Is it the first time?” and “Has anything actually changed?”. Suddenly our good intentions have brought us a host of work and maintaining the date stamps is starting to look painful.</p><p>Can all this date stamping malarky be done in an easier way? Of course it can! It can actually be done automatically and once you have set up your objects and date stamping code you can then forget about it until you need to examine those dates.</p><p><strong>Data Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*ZmxuVum0Dnn9AjyFJQEM7A.png" /><figcaption>SignatureManagedObject</figcaption></figure><p>First create your model. We will use <strong>SignatureManagedObject</strong> to help encapsulate our need for two date stamps.</p><p>Each object in your model that needs date stamps inherits from <strong>SignatureManagedObject.</strong></p><p>I’m a simple guy so when I do this I make every object in my model inherit from <strong>SignatureManagedObject.</strong></p><p><strong>date_created</strong> and <strong>date_modified</strong> are of course Date types. Let’s check the identity inspector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*i-do0BZp2Gh_oyj4QdEgXw.png" /><figcaption>Identity Inspector</figcaption></figure><p><strong>The Magic (Automation)</strong></p><p>In SignatureManagedObject.swift add the sign() method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6cIkKwcPZJhLR1b_9vUNg.png" /><figcaption>SignatureManagedObject::sign()</figcaption></figure><p><strong>Core Data Stack</strong></p><p>Moving the Core Data Stack out of the AppDelegate is a topic for another post. For now we will adapt Apple’s current boiler plate code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MWvBY2QYrki4TUsB1ILLow.png" /><figcaption>Making use of sign() when the context is being saved.</figcaption></figure><p>Now what happens when you call saveContext() is any new objects (those being inserted) are signed and any modified objects (those being updated) are signed.</p><p>Thanks for reading &amp; good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd5f0dec392b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UIAccessorizedTextField]]></title>
            <link>https://medium.com/@dfplaughton/uiaccessorytextfield-5ca735f09cef?source=rss-e9bb96b29f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ca735f09cef</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Damien Laughton]]></dc:creator>
            <pubDate>Wed, 28 Mar 2018 15:24:55 GMT</pubDate>
            <atom:updated>2018-04-20T16:48:58.725Z</atom:updated>
            <content:encoded><![CDATA[<p>Many a time I have been asked to implement a drop down text field in an iOS app.</p><p>Thankfully those times are getting rarer and recently I had a lightbulb moment and suggested we use an <strong>Input Accessory View</strong> to facilitate text field choices for the user.</p><p>Input Accessory View’s are common place these days in iOS, here’s one for reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*hwNwn_BH4tuwMcII4BVL-g.png" /><figcaption>Input Accessory View often used to help out during form filling.</figcaption></figure><p>My problem was to show the user a list of previously entered email addresses in a <strong>UITextField</strong>.</p><p>Because device footprint is an absolute premium in mobile it’s often beneficial to take a moment during design or elaboration phases of work to think about how best to implement a UI Control so that it’s integration into a UI/UX flow is as seamless as possible.</p><p><strong>UIAccessorizedTextField</strong></p><p>UIAccessorizedTextField is a UITextField subclass which when tapped and the keyboard shows will add an Input Accessory View which contains a UICollectionView of Strings which the user can tap to choose. This is what it looks like in action.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_ZhpZWsr-Oc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_ZhpZWsr-Oc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_ZhpZWsr-Oc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a564814ff10ea76ff50d9a8a21591c1/href">https://medium.com/media/5a564814ff10ea76ff50d9a8a21591c1/href</a></iframe><p>Setting up a UITextField to behave as above is very easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*gtFIB8Y1ocfhxeUVhPMvOQ.png" /><figcaption>Configuring the UIAccessorizedtextField.</figcaption></figure><p><strong>Code</strong></p><p><a href="https://gist.github.com/damienlaughton/ef4dd0ad5f6dd52362b2c7100fe0d167">Here is the code in a gist</a>. It’s all in one file for portability. Use it if you like. I retain no rights to the code you can just do as you wish.</p><p>If you liked this you may like:</p><p><a href="https://medium.com/@dfplaughton/kerning-pardon-93dbe1b5d366">Kerning — pardon?</a></p><p>or</p><p><a href="https://medium.com/@dfplaughton/nsmanagedobject-auto-date-stamping-cd5f0dec392b">NSManagedObject + Auto Date Stamping</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ca735f09cef" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>