Adding a contact to the user’s address book on Apple platforms using the prescribed method requires jumping through a lot of hoops. You have to: add NSContactsUsageDescription to your info.plist add an entitlement to your app ask the user for authorization (requires an in-app popup) if you want...
Even though they are sometimes overused, enums are still a great tool. Thanks to Codable they can easily be decoded from JSON sent by your backend. This is great until you need to add a new case to the enum. Then you have to either deal with versioning your API or you need to tell your users...
I often see a pattern where there is an enum with a bunch of computed properties that return a different value for each case. In the rest of the code base then only those properties are used. Something like this: enum Style { case headline case bodyText case emphasis var...
While investigating the new AttributedString API I realized you could use the same techniques to build a generic fluid builder interface for any type. This is what I came up with:
And here is an example how you can use it:
Finally we are going to get attributed strings as a native Swift value type. So lets see how we can update the example of my last article about attributed strings: let string = "Name (whatever)" var attributed = AttributedString(string) let nameEnd = attributed.range(of: " (")?.lowerBound ??...
CoreData and discarding changesAt the end of the latest Swift by Sundell podcast, John and Donny talk about discarding changes in CoreData without hitting the database.This is actually really easy to do with the proper setup.John suggest creating an intermediary Struct that we can either throw...
You may know that you can configure a UI component with an accessibility label. The accessibility label is the name of the component. You can also configure an accessibility trait. The accessibility trait is the role of the component, it gives the user information on how they can interact with it....
The cycle for creating great accessible apps starts and ends with testing. Sure, it is always better to get feedback from users to create an experience that holds up to their expectations. But that’s not always possible. Till you can do it, I think the way to go is to do your best. Build it as...
New Macs will use Apple-developed processors, not Intel. This new architecture has been named Apple silicon. Initial Developer Transition Kits (DTKs) are ready to be shipped to developers. They will pack the A12Z processor of the iPad Pro. Many apps are already being ported to leverage Apple...
I know, iOS 13 has been with us for quite some time now, WWDC 2020 is just around the corner and we hope Apple will present again a ton of new accessibility features and improvements coming with iOS 14.But it is almost Global Accessibility Awareness Day! And it is still a great time to catch up...
I had to take a string like “Name (whatever)” and display it in a label. The Name part should be bold, and anything in parentheses should use the regular font. Pretty simple, I just put the string in a NSAttributedString, find the opening parenthesis and add a bold font attribute to everything up...
Apple introduced iOS 11 at their World Wide Developer Conference (WWDC) in June 2017. WWDC is Apple’s showcase of new tools and developer APIs covering iOS, macOS, watchOS, and tvOS. In this post we’d like to show you what’s new in accessibility in iOS 11, and how you can incorporate these...
Especially on iOS it’s often necessary to create new objects like new view controllers or such things. This often cannot be avoided. This usually is solved by having the object that creates new objects also require all the dependencies of the objects it wants to create. This of course is not a...
I recently read the article “Using protocol composition for dependency injection” by Krzysztof Zabłocki. I found this to be a rather interesting technique for doing DI, but when trying to implement it I found it somewhat limited: It doesn’t really handle dependencies that have dependencies...