Errata in Swift book by Apple

In App Development with Swift, by Apple

Unit 2: Introduction to UIKit

Lesson 2.5: Collections

Playground: Lab – Collections, Page 1

Call removeLast() on myArray. If done correctly, this should remove Rebecca from the collection. Store the result of removeLast() into a new constant deletedItem, then print deletedItem.

myArray was never suggested as a name for a variable, I am sure the correct variable name is registrationList, as indicated since first paragraph of this playground.

Posted in iOS | Leave a comment

Errata in Solution in Swift book by Apple

Book: App Development with Swift, by Apple

Unit 2: Introduction to UIKit

Lesson 2.5: Collections

Question: “Which piece of code will insert an item into the set of integers, bankAccounts?”


Suggested solution is wrong. Maybe I am confusing the question, but i am pretty sure the question intention was about the unique wrong option.

Posted in iOS | Leave a comment

Xcode workspace + keyboard shortcuts

Here I share my Xcode workspace and some keyboard shortcuts for nice development workflow

It consist in 2 windows. One for Storyboard and the other for Code and Debug.

Window 1: Storyboard

Xcode - Storyboard window

That window contains just one tab. Then we will watch two tabs in the second window.

Included panel:
– Document outline
Hidden panels:
– Debug Area
– Navigator

Useful shortcut:
– Zoom-out storyboard: ⇧ + ⌥ + ⌘ + {

Tip: This Storyboard window can be closed when we stop using it, e.g. when there are no more modifications to interface by means of the Storyboard. Then we would have only one window for Coding and Debugging.

Window 2: Code and Debug

Useful shortcut:
– To go to the second window or to go back: ⌘ + ~
Previous one is a OS X shortcut to go to next window of same application.

Tab for Coding:

Xcode - Code tab

Included panel:
– Navigator. Showing Project Navigator view.
Hidden panel:
– Debug Area

Useful shortcuts:
– Document view, to explore properties and methods in current file: ⌃ + 6
– Quick open, to open a file with autocomplete search mode: ⌘ + ⇧ + O

Tab for Debugging:

Useful shortcut:
– To go to the second tab: ⌘ + ⇧ + }

Xcode Debugging tab + Simulator

Useful shortcuts:
– Run app in Simulator: ⌘ + R
– Return to Xcode (to stop the app): ⌘ + ⇥
(previous is a OS X shortcut)
– Stop the app: ⌘ + .
When debuggin:
– Step over Breakpoint: f6 (fn + F6)
After debugging:
– Close opened file: ⌃ + ⌘ + W
– Clean Console: ⌘ + K

Posted in iOS | Tagged , | Leave a comment

Consuming RESTful API on Rails

It’s great to consume APIs. Here we got a Rails way to do this. For this example code we will use “Week” model.

Note: If RESTful API its provided by default Rails, json.builder files and methods in controllers should be working.


1. Include ActiveResource in Gemfile

2. Execute “bundle install” in command line

3. Declare the model that inherits from ActiveResource::Base. There we need to define the uri for API consumption.

4. Create a Controller and “index” method. In this example code, we just retrieve all records.

5. Include weeks in routes.rb

6. Now we can use the Object Collection. Just render @weeks

7. Yes! It’s better to use the _week.html.erb partial to render each object in the collection


Posted in Ruby on Rails | Tagged , , , , , , , | Leave a comment

Dynamic and meaningful titles on our websites

Let’s work an important feature of our web apps: Page titles. These provides a better experience for the visitor.

While developing a website we use to have our broswer full crowded of tabs. The only way to know in which tab is the page we are looking for is by means of Page Title.


1. Create a method that generates markup for the layout

2. Set a meaningful title using previously defined method. Neat detail is that we can use variables, so now our titles are dynamic!

3. Use title defined in the View. It’s a good practice to include a default value, “My Website” in the example code.

That’s all. The power to titles can be provided by variables defined and constructed in controllers. Use methods of your models to obtain great titles.

Posted in Uncategorized | Tagged , | Leave a comment

Access Class’ CONSTANT value from JavaScript

Let’s say coffeescript, properly.

First. Declare a CONSTANT in the model and assign a value to it:


Rename the file to First language be processed will be Ruby. Assign the constant value to a javascript variable with the classic shorthand:

Posted in Ruby on Rails | Tagged , , | Leave a comment

Turbolinks conflict with JQuery

Rails 4 incorporates Turbolinks. This “accelerates” page load, usign Ajax calls for content retrieval. Pages load pretty fast… but… JQuery doesn’t load the first time a page loads, it only works after refreshing or on reload.

To solve this, we can use jquery-turbolinks gem. Include it in Gemfile

Then, require it on Javascript application

Posted in Ruby on Rails | Tagged , | Leave a comment