Sometimes you may wish you could tweak some values of your app (colors, font sizes, text) while you test it in the field. Or you would like to enable a feature to test it but don’t like to show that feature to your beta testers yet.
With my framework DDHTweaks you can do exactly this. You just need to add a bit of code to be able to change some values while the app runs.Read more...
Sometimes you need to add automatic tests for the UI of your app. There are several different approaches to achieve this.
In the test you could get the elements of the screen and assert if all the frames are as you expect. Depending on the UI you want to test, this can be a lot of work.
Or you could use UI tests provided by Xcode. But those are extremely slow and in my experience sometimes they just stop working.
There is a better alternative. Facebook has an open source component calledRead more...
FBSnapshotTestCase. This class allows you create snapshot tests. A snapshot test compares the UI of a view with a snapshot of how the view should look like. Let’s see how this works.
Did you know that you can create your own file templates for Xcode? Sure you did. But did you also know that you can create a template that takes a string and puts it into a field you define?
Let’s build a file template for a Swift protocol and a protocol extension.
Create a file template
First things first.
Xcode looks for your custom templates at the locationRead more...
~/Library/Developer/Xcode/Templates/. We will start by copying a template that comes with Xcode to that location.
The 4th problem in Project Euler is this:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Yesterday I gave a talk at the Cologne Swift meetup and I tried something new. I used a Swift Playground for the “Slides”.
Yesterday I got asked, what a Swift beginner should learn first. Here is the question:
I did want to ask you something, is it worth a while to learn TDD, or spend that time learning Swift, and functional programming?
Of course, my opinion is a bit biased as I wrote a book about TDD with Swift. So, keep that in mind when you read my answer.
Advice #1: Read the Swift Book provided by Apple.
In my opinion you should first learn Swift. This is the basis of everything. If you don’t understand what functions can do in Swift, you won’t understand the concepts of functional programming in Swift. In addition, Swift is still mainly used to write apps for iOS and OS X. This means, most of the time you need to interact with object oriented APIs (at least at the time of writing ;)). So you also need to understand object oriented Swift to leverage the potential of Swift when writing Swift.
And even if you don’t believe me, this is what Chris Eidhof, Florian Kugler, and Wouter Swierstra write in Functional Swift:
„You should be comfortable reading Swift programs and familiar with common programming concepts, such as classes, methods, and variables. If you’ve only just started to learn to program, this may not be the right book for you.“
With the new syntax for selectors in Swift 2.2 the approach I used in “Utilize the responder chain for target action” produces a warning. Let’s fix that.
Protocols for president
First we add a protocol:Read more...
I got some feedback to my last blog post about The best table view controller. In this post I want to comment on the feedback because the comment sections is not really good for detailed discussion.
I couldn’t get Interface Builder in Xcode 7.3 to support typed view controllers. While you can type in the associated class, the field becomes blank when the storyboard is saved.
Interesting. I wasn’t aware of this. But this again tells me, that storyboards (and the Interface Builder in general) are not suited for my style of iOS development. As you may know, I don’t like the Interface Builder.
If you depend on storyboards for your User Interface, than this kind of table view controller isn’t for you (yet).Read more...
Since I read the objc.io post about light view controller, every few month I come back to the same problem: find the best way to write a table view controller. I have tried several different approaches like putting the data source and delegate in a separate class or using MVVM to populate the cell.
This post is the March 2016 solution to this problem. And as most of the times, I’m quite happy with the current solution. It uses generics, protocols and value types.
The main part is the base table view controller. It holds the array to store the model data, is responsible for registering the cell class and it implements the needed table view data source methods.
Let’s start with the class declaration:Read more...
Last month my book about Test-Driven Development with Swift finally got published. In this and some of the next blog posts I will present some things I learned while I wrote it.
In this post I will show a nice way to test if a view controller got pushed onto the navigation stack as a result of an event.
Let’s say we have button on a view controller. When the user taps the button, a detail view controller should be pushed onto the navigation stack. How can we test this?
Easy! We will use a mock for the navigation controller. The mock looks like this:Read more...
subscribe via RSS