By Developers, For Developers

Historical errata for RubyMotion

PDF PgPaper PgTypeDescriptionFixed onComments
3TYPO

The header of the comment box reads “$.:unshift”.
Everywhere else on the page it reads “$:.unshift”.

2014-06-14
3TYPO

“The first two lines import necessary…” - the first line is just specifying the file encoding, so instead this should refer to lines 2 to 3.

2014-06-14
12TYPO

The text refers to the method application:didFinishLaunching: rather than application:didFinishLaunchingWithOptions:

2014-06-14
17SUGGEST

I think the animation code sample would be difficult to read for beginners. It has 7 levels of indentation, something which many Ruby programmers would from upon.

Perhaps it would be clearer if the animations and completion lambdas were first assigned to local variables, and then passed into animateWithDuration?

2014-06-14
19SUGGEST

Rather than using #select and then negating the expression with #not, it might be clearer to use #reject.

2014-06-14
87TYPO

It says add find method to user, but it should be color

2014-06-14
57ERROR

cell = UITableViewCell.alloc…should really be ||= in this case (in case you dequeued an already active cell).

2014-06-14
56TYPO

in the definition of tableView:cellForRowAtIndexPath: there is a rogue ‘end’ keyword.

Also there on line 35 of the file below when following the link in the PDF.
/TableFun_basic/app/controllers/alphabet_controller.rb

2014-06-14
15ERROR

URL in the footnote doesn’t work. Should probably be:

developer.apple.com/library/ios/#documentation/uikit/reference/UIControl_Class/Reference/Reference.html

2014-06-14
78ERROR

There’s an extra ‘end’ in the code at the top of the page for ‘search_controller.rb’. It’s the ‘end’ just above the open_color method.

2014-06-14
1SUGGEST

On the Kindle version, the code font is significantly smaller than the text. In order to read it, I have to amp up the zoom a lot more than I’d like. Can the code font be increased to be more consistent with the rest of the book?

2014-06-25
81TYPO

The text says that we’re going to add this method: Color#add_color() to color.rb, however in the code we implement Color#add_tag()

2014-06-14
56TYPO

The bug is on page 56 (as printed on the PDF page), or 67 (as numbered in Mac Preview.app)

It’s in Section 5 (right before 5.2) on UITableView

Here is the code correction & bug:
gist.github.com/4458641 (links arent allowed)

If this code isn’t right (although it works), please let me know the correction! Thank you!

@stevemanuel

2014-06-14
xiTYPO

‘sounds good?’ … not ‘sound good’

2014-06-14
15SUGGEST

I think it would be worth it to spend a moment and explain why it’s UIView.alloc.initWithFrame(…) and not UIView.new.initWithFrame().

To me, it’s not very Ruby-like to use .alloc, and looks just plain ugly.

Why not .new ? What’s the difference?

2014-06-14
27OK

The filename above the code examples does not match what it would be if you are following along. For example, in Chapter 2, in section 2.3, the filename shown is “views/Boxey_buttons/app/app_delegate.rb”. In 2.4, it is “views/Boxey_animations/app/app_delegate.rb”.

If following along with the book, it should be “./Boxey/app/app_delegate.rb”.

Minor thing but it keeps making me go back and double check to make sure I didn’t miss anything.

74TYPO

Double dot in the filename earch_controller.rb just above the source code

2014-06-14
19TYPO

First line: “we just to give it a box elsewhere in our code”. The “to” is either superfluous or should be replaced with “have to”/“need to”/etc.

2014-06-14
56ERROR

Extra “end” in the listing of alphabet_controller.rb in section 5.1: the first end shown, in the middle of the function, is unmatched.

def tableView(tableView, cellForRowAtIndexPath: indexPath) reuseIdentifier ||= "CELL_IDENTIFIER" cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier)
UITableViewCell.alloc.initWithStyle(
UITableViewCellStyleDefault,
reuseIdentifier:reuseIdentifier) end <<<<<----This end is unmatched and should be deleted cell.textLabel.text = data[indexPath.row]
cell
end

2014-06-14
76ERROR

If the app is as advised on this page, it crashes on the button.addTarget call. Commenting this call out solves the problem.

‘tap_red’, etc. are not added to colors_controller.rb until the following page.

(I’m running RubyMotion 1.32)

2014-06-17
78ERROR

After making the changes up to page 84, if you select the “Top Color” tab its name changes to “Detail”. This can be fixed by moving ’ self.title = “Detail” ’ in the color_detail_controller code on page 78 from viewDidLoad to initWithColor(color).

2014-06-14
15ERROR

URL at bottom to is dead

2014-06-14
74TYPO

There are two dots before the “rb” extension of the file “search_controller.rb”, approx. half way down the page:

Let’s start setting up these elements. Open search_controller..rb

2014-06-14
76TYPO

We aren’t dealing with a User model; we are dealing with a Color model. Approx. 3/4 of the way to the bottom of the page:

It’s time to add that find() static method to our User.

2014-06-14
56TYPO

The sample code “alphabet_controller.rb” miss ‘|| begin’ at the end of 4th line. The correct sample code is on rubymotion-tutorial.com/5-tables/

2014-06-14
55TYPO

“if we don’t have one (nil), we run the begin/end block.” There isn’t a begin/end block in the sample code on the previous page.

2014-06-14
20TYPO

I’m getting an undefined method error for ‘initWithTitle’ from the UIAlertView in app_delegate.rb. Could this be due to an iOS update? My versions are:

Xcode 4.6.2 with the command line tools installed
OS X 10.8.3

Stack trace below:

#######################

Execute simulator
DYLD_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/../Frameworks /Library/RubyMotion/bin/sim 2 1 6.1 “/Applications/Xcode.app/Contents/Developer” “./build/iPhoneSimulator-6.1-Development/HelloMotion.app”
(main)> 2013-04-22 12:03:35.881 HelloMotion[2790:c07] app_delegate.rb:12:in `application:didFinishLaunchingWithOptions:‘: undefined method `initWithTitle’ for # (NoMethodError)
2013-04-22 12:03:35.883 HelloMotion[2790:c07] * Terminating app due to uncaught exception ‘NoMethodError’, reason: ‘app_delegate.rb:12:in `application:didFinishLaunchingWithOptions:’: undefined method `initWithTitle’ for # (NoMethodError)

* First throw call stack:
(0x1809012 0x179e7e 0xd8954 0x2e12 0x2bc5)
libc++abi.dylib: terminate called throwing an exception

* simulator session ended with error: Error Domain=DTiPhoneSimulatorErrorDomain Code=1 “The simulated application quit.” UserInfo=0x101a1e690 {NSLocalizedDescription=The simulated application quit., DTiPhoneSimulatorUnderlyingErrorCodeKey=–1}
rake aborted!
Command failed with status (1): [DYLD_FRAMEWORK_PATH="/Applications/Xcode.a…]

2014-06-14
5544SUGGEST

There is a loop that does what the attr_accessor method does by default with multiple arguments:

PROPERTIES = [:id, :name, :email]
PROPERTIES.each do |prop|
attr_accessor prop
end

becomes

attr_accessor(:id, :name, :email)

Seems like blatant ignorance of Ruby idioms.

2014-06-14
5544SUGGEST

The above code needs to be amended to add the PROPERTIES constant

PROPERTIES = [:id, :name, :email]
attr_accessor *PROPERTIES

2014-06-14
23ERROR

Teal is not one of the predefined colors. I believe you meant cyan.

2014-06-14
24TYPO

view.move_to [view.frame.origin.x, view.frame.origin.y - (@last_view.frame.size)]

last_view.frame.size should be last_view.frame.size.height

2014-06-14
35ERROR

def initWithNibName(name, bundle: bundle)
super
self.tabBarItem= UITabBarItem.alloc.initWithTitle(“Other”,
image: nil,
tag: 1)
self
end

this added this codeblock changes nothing :-(

i changed the title but the tab still have the text from the selft.title in viewDidLoad

2014-06-21
36ERROR

this works:

self.tabBarItem=UITabBarItem.alloc.initWithTabBarSystemItem(UITabBarSystemItemFavorites, tag: 1)

2014-06-21
36SUGGEST

def change_color
color_text = @text_field.text.downcase color_method = “#{color_text}Color”
if UIColor.respond_to?(color_method)
color = UIColor.send(“#{color_text}Color”)

last line should better:

color = UIColor.send(color_method)

2014-06-14
76ERROR

“It’s time to add that find() static method to our User. We’re finally going to play with HTTP requests here, starting with HTTP.get.”

Should be “Color” instead of “User”

2014-06-14
57TYPO

cell = tableView.dequeueReusableCellWithIdentifier(@reuseIdentifier)

#this block should not indicated as new insertions
#instead of cell = - it should be cell ||=
➤ cell = UITableViewCell.alloc.initWithStyle(
➤ UITableViewCellStyleDefault,
➤ reuseIdentifier:@reuseIdentifier)

➤ cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator

2014-06-14
19TYPO

On the transition between page 18 and 19, looks like the word ‘have’ is missing from this sentence:

“we just to give it a box elsewhere in our code”

2014-06-14
18TYPO

“This will handle figuring out the index of the box and adding the UILabel; we just to give it a box elsewhere in our code, and it will work.”

I guess a word is missing… The sentence is not understandable.

2014-06-14
11TYPO

Last sentence on page 11 reads “frames have a origin”. Should be “an”: “frames have an origin”.

(The sentence might read easier if it were recast: “Every frame has an origin property with which you can access the x and y coordinates, as well as a size property that defines the view’s width and height.” At least this avoids beginning the sentence with a lower-case letter.)

2014-06-14
39ERROR

To prevent a crash if the User clicks on the “change” button before they add a color.

In change_color_controller.rb file, add a line just before the @text_field is added to the subview:

text_field.text = ''; # Added Line prevents a crash. self.view.addSubview(text_field)

2014-06-14
66TYPO

In this paragraph :
The generated test in main_spec also has the describe() and it() blocks, which add structure to our tests. You can read the combination of the two blocks like a sentence: “Test that application ‘Tests’ has one window.” A describe() block can have many it() blocks, and an it() block can have many assertions. You can even nest describe()s to create very granular descriptions of each test. We’ll see the results of all this structuring in just a second when we run the tests.

“Test that application ‘Tests’ has one window.”
Should probably rather be
“Test that application ‘TestFun’ has one window.”

2014-06-14
1TYPO

This is a bug with the web page for the book, not the book itself. On the Details page on PragProg it says “Q&A with Clay Allsopp, author of RubyMotion.” Should that say Laurent Sansonetti? Clay is the author of the book; Laurent is the principal author of the software.

68SUGGEST

When the button is created it appears to be covered by the status bar. This causes the test to fail. Simply pushing the button down below the status bar resolves the issue for me:

button.frame = CGRect.new([10, 70], button.frame.size)

-Matt

2014-06-17
46ERROR

a popular RubyGem called BubbleWrap bubblewrap.io that “wraps” many

That link is dead

3TYPO

First sentence after code snippet: “The first line specifies the the file encoding…” contains duplicate ’the’s

37TYPO

First line:

“This present a few problems”

should be ‘This presents a few problems’

86TYPO

First line of second paragraph:
“Now that we have some our UI set up”
is not grammatically correct.

Categories: