I just bought your book, and nothing works right


#1

Every lesson I have tried so far in the “iPhone Programming The Big Nerd Ranch” comes up with errors when I try to do a build.

The book was just purchase brand new from Chapters and it is Second printing, August 2010 edition.
I am using Xcode version 4.0.2

In trying to code Subclassing UIView – chapt. 6
I did have some type errors, but mostly because the Xcode program throws in a name similar to but different than the correct one.

I’m getting a “Thread 1: Stopped at breakpoint 1” stoppage or interruption. The code builds with no issues. It just won’t load in the simulator. Below is the break point:

//From the center how far out to the corner? float maxRadius = hypot(bounds.size.width, bounds.size.height) / 2.0;

I need help and I’m hoping Mr. Conway, you can offer assistance on this. I’m feeling a little abandoned here because I posted a request for help on July 7 for one of the first problems I encountered and to this date there has not been one reply for it.

–Rob


#2

I am kind of getting the same feeling, I am not getting any errors the apps just don’t work.

The map view did not find my location.

And now I just finished writing the hypnosis app and the result was one small circle nothing else! It is supposed to generate circles until it touches the edges. I think the error lies in this part of the code:

[code]//
// HypnosisView.m
// Hypnosister
//
// Created by Benjamin Waye on 8/19/11.
// Copyright 2011 MyCompanyName. All rights reserved.
//

#import “HypnosisView.h”

@implementation HypnosisView

-(void) drawRect: (CGRect) rect
{
// What rectangle am I filling?
CGRect bounds = [self bounds];

// Where is its center?
CGPoint center;
center.x = bounds.origin.x + bounds.size.width / 2.0;
center.y = bounds.origin.y + bounds.size.height / 2.0;

// From the center how far out to the corner?
float maxRadius = hypot(bounds.size.width, bounds.size.height) / 2.0;

// Get the context being drawn upon
CGContextRef context = UIGraphicsGetCurrentContext();

// All lines will be drawn 10 point wide
CGContextSetLineWidth(context, 10);

// set the stroke to a light gray colour
[[UIColor lightGrayColor] setStroke];

// Draw concentric circles from the outside in

[color=#FF0000] float currentRadius = maxRadius;

for (; currentRadius > 0; currentRadius -= 20);[/color]
{
    CGContextAddArc(context, center.x, center.y, currentRadius, 0.0, M_PI * 2.0, YES);
    CGContextStrokePath(context);
}

}
[/code]

Which I had to change because I kept getting an error that currentRadius had not been defined in the CGContextAddArc. What did other people do to solve this?

EDIT: Replaced the whole drawRect method with this one

- (void)drawRect:(CGRect)rect { CGRect bounds = [self bounds]; CGPoint center; center.x = bounds.origin.x + bounds.size.width /2.0; center.y = bounds.origin.y + bounds.size.height /2.0; float maxRadius = hypot(bounds.size.width, bounds.size.height); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 10); [[UIColor lightGrayColor] setStroke]; for (float currentRadius = maxRadius; currentRadius >0; currentRadius -=20) { CGContextAddArc(context, center.x, center.y, currentRadius, 0.0, M_PI * 2.0, YES); CGContextStrokePath(context); } }

And now it works it no longer presents an error when I write the CGContextAddArc method any suggestions why?

EDITEDIT:

NVM I FOUND THE TYPOS xD still don’t get the map view though,