Enumerations have much more power in Swift than in C. For one they are not restricted to integer type, e.g. they can be created with “raw” String value and still be matched in switch expression. They can even contain associated values! Canonical example here is Result, used for error handling.
Let’s look further than that. Associated value data can be of any type: struct, class, enum or even closure. This opens great possibility for passing around configurations with enum cases.
When we have an app with lots of input forms, implementing them gets tedious very quickly. We really want to streamline the process. There are a bunch of libraries dealing with this. However, such big universal solutions come with a cost. It includes time spent familiarizing with framework’s intricacies, running into limitations and working around them. Along the way some needed feature may just not be there. Fork time. All of this can be more effort than building solution that matches our specific needs. Tradeoffs, right?
As an alternative, below is a set of simple guidelines that work both for dealing with static and dynamic collections of items. To keep example brief, it deals only with a few cell types: one for text input, one for selection from group of options, and one for boolean values.
The original post is published on the Tivix blog at the following URL: http://www.tivix.com/blog/aranalytics-analytics-clean-code-crash-logs-on-ios/
Tracking how users are using your app is a must. When looking for improvements we should rely on data, instead on just a hunch. There are a lot of analytics services and each of them has its own SDK. Integrating different analytics services, adding code for logging events and screen views, is at best tedious and bloats code in places that are already susceptible to it (Hello, Massive View Controllers). Switching to another service leads to changing code all over the app. By default it’s also impossible to just quickly try out a new provider, without repeating work that’s already been done.
But it’s not all doom and gloom! ARAnalytics is an Objective-C library helping with integrating those services into iOS and OS X apps. It’s a wrapper, that reduces an overhead of learning yet another framework. Currently it supports 32 different services. Just integrate one of the providers available in ARAnalytics, set it up with API key and it’s done. Library has all the standard tracking features for events, timed events, screen views, and errors. Thanks to using one consistent API, developers can add and drop support for analytics services at will, without going through the hassle of making code changes in many places.
Below I’ll explain how to set up ARAnalytics and take advantage of its great features that will help keep code DRY and get more insight from crash logs.
Automated tests save time and give confidence when refactoring code.
How one would go about starting writing tests in Swift? There’s a bunch of ways to do unit testing, different styles (TDD, BDD), different matchers. Before delving into any of this, let’s make sure our testing setup is up to date with Swift 2/Xcode 7 capabilities.