About the iOS Apprentice category

These are the official forums for the iOS Apprentice, our book on beginning iOS development.

This is the place to ask any questions you may have about the book. We hope you enjoy the book! :]

1 Like

Hi Guys,

I am working through the iOS Apprentice Guide #1 building the Bulls Eye game and have run into a road block. I cannot get the “ok” button to respond to my click actions. I have reviewed the source code against the code provided and cannot find any errors. Also I have actually downloaded the final source code of the completed project and cannot get it to work either. Still no action when I select the “ok” button on the game. Any ideas or suggestions? So far have really enjoyed the tutorial; just want to finish it. Thanks!

Are you talking about the OK button in the alert?

Yes when I click on the “Ok” button nothing happens; I cannot get the game to reset.

You are further ahead in the tutorial then me so you can ignore anything I have to say but I am interested in your issue. When I was stuck (I had accidentally put a breakpoint into the code) and went and looked at the source code at the stage I was stuck at it pulled up a second xcode window that functioned properly. is that happening for you.

I went through all the code and could not see the issue so I started checking to see if the buttons were hooked up correctly.

I ended up commenting out(/** */ )my whole block of code, and copying and pasting in the source code below it.(I was only at level 2 at the time).

my idea was that if it did not work then it was in the buttons. It ended up not being a correct assumption and it was a breakpoint I will now always look out for.

This most likely wont help you but maybe it will. Let me know what you find and what stage you are on. I will try and break my code when I get there.

Thanks for your reply Derek,
I think I will wait until you get further along in the tutorial and see if you have the same issue. I failed to let you know that I actually loaded in the completed source code provided in the resources file and it did not work either.

All the best,

How do you do a search in the forums now??! I can’t find this most basic of functionality having spent half an hour looking for it. Need to find a particular post of mine which had a couple of fixes for a tutorial but can’t find it.


Hi Huys,

I have already finished the iOS Apprentice tutorials #1 #2 #3 #4 in the Swift language (It’s the great book, help me understand a lot of things), and now I am looking for the iOS Apprentice tutorial #1 #2 #3 #4, which supported in Objective - C. Can somebodies help me where to find those tutorials ??

My Writing English skill is little, so sorry for any inconvenience.

Thanks! :blush:

If you bought the PDF version, you can go to www.raywenderlich.com/loot and download the old Objective-C version for free (2.1). However, this uses an old version of Xcode and some of the things no longer work.

Oh thanks you so much! and I have another question that when do we have the Swift 3 version ?

I recently purchased "iOS Apprentice fifth edition… I had already downloaded the “…Getting started” long before, from my loot. After I purchased the full book, it now appears in my loot (replacing the getting started icon). But when I download it, it doesn’t download the full version. It continues to downloads the “Getting Started” version, with only the first tut. I don’t see the other tutorials. Please, how can I correct this? Thanks

There are 4 separate downloads, one for each tutorial. If you’re only seeing one of them, then something is wrong.

Unfortunately, I can’t fix that for you. It’s best if you contact Ray directly through the form at: http://raywenderlich.com/contact

Sorry for the inconvenience!

1 Like

I’m working through tutorial 1 (v5.0) of the series, creating the Bulls Eye game. I get a very strange fatal(?) error when I hit the OK button, where the entire screen goes black, briefly flashes some error regarding

...kernel-internal importance assertions for pid 820 (com.apple.dock.e), dropping 1 assertion(s)...

and then it boots me out to the login screen. Upon logging back in, there is no error in Xcode, the simulator is still running, and the “score” window that should have been created is not present.

The problem goes away entirely when I change the line

let title: String


var title: String

The same behavior occurs when I run the copy/paste code included with the PDF’s

The only caveat to this entire thing, is that I’m running a (assumed properly configured) OSX 10.11.6 in a Virtual Box VM instance on a PC.

Being very new to swift, just about the only thing I can think of is that it doesn’t like the “let” specifier being used when you’re not immediately doing its associated initialization? “Let” is supposed to be treated like a constant, yet the way the code is written, you’re creating the constant “title” yet leaving it uninitialized?

The difference between let and var should not matter in this case.

Because the error message comes from “kernel-internal”, the crashes sound related to the fact that you’re not running Xcode on a native Mac.

1 Like

Thanks for the reply. I guess I’ll start tracking down an actual Mac.

Got worked out. Thanks.

In Chapter 31, given a way to change the cell selected color by following:
let selection = UIView(frame: CGRect.zero)
selection.backgroundColor = UIColor(white: 1.0, alpha: 0.3)
cell.selectedBackgroundView = selection
CGRect.zero seems like the selection view is zero size , how can it automatically fit the cell size?

You’re likely to get more responses if you start a new thread than ask an unrelated question in this thread :slight_smile:

That said, while the background view does start with zero size, I believe it adjusts to the height and width of the cell automatically because the cell size itself can change dynamically as the content displayed changes. If the background view remained the same size always, then you would have to manually adjust the width and height of the background view each time your content changes …

Thanks for your reply, I found the explanation in backgroundView property discussion: The view you assign to this property is positioned underneath all other content and sized automatically to match the enclosing clip view’s frame. They just action the same way I suppose.

You mean the Ok button in the pop-up alert?