All posts by Valerio Ferrucci

Valerio Ferrucci (valfer) develops software on Apple Macintosh since the 1990s until today for MacOS, OSX and, since some years, iOS. He is also a Web (PHP/MySQL/JS/CSS) and Android Developer.

Swift JSON Parser – Part 3

Sometimes it happens to me to observe my code and to say: “no, these things should be made differently”. Then I go into “refactoring”. I think this is an important step of every programmer. Don’t be afraid to refactor (don’t listen to the voice inside you: “… don’t touch that code! Nothing will work correctly after changing this single byte …”): code is something always in evolution (and in test …).

Seeing the code of Part 2 I don’t like two different callbacks to be passed to the start method:

Continue reading Swift JSON Parser – Part 3

Swift JSON Parser – Part 2

In this post we continue the development of a JSON Parser starting from the previous one: Swift JSON Parser – Part 1.

Let us begin handling the “something went wrong” part.

Error handling strategy

Two types of “bad things” can happen:

  1. The parser has an error before looping on the elements of the array: this can be a reader error or the json returned is not of type [AnyObject?]
  2. The parser starts but has an error on one of the element inside the loop

Continue reading Swift JSON Parser – Part 2

iOS8 Self Sizing UITableView Cells

The UITableView is a class we all have used at least once in our apps.

Sometimes we need a UITableView with cells all equal in height, but sometimes we need dynamic height cells, each one having a different height, typically dependent on its own content.

The old way

Before iOS8, this was not trivial since the system needed to know in advance the overall height of the table in order to set the content size of the scrolling area (UITableView inherits from UIScrollView).

Continue reading iOS8 Self Sizing UITableView Cells