Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning iPhone SDK Programming with Objective-C
This is the forum to discuss the Wrox book Beginning iPhone SDK Programming with Objective-C by Wei-Meng Lee; ISBN: 978-0-470-50097-2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iPhone SDK Programming with Objective-C section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 21st, 2010, 09:51 AM
Registered User
 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page 66-67, app crash

When I run the secret PIN version of the BasicUI app, it will not accept PIN entry. When I click on the pin buttons, the app crashes. My code builds and runs with no errors or warnings.
I also believe there's an error on page 66. Some of the code that needs to be entered is not in bold.
This book is already a bit outdated as the SDK no longer allows you to create outlets and actions in the way the book describes. I finally found the errata page. Its not the simplest to find as somehow I ended up on the ebook version first.

All this makes it difficult to flow through this book.

  #2 (permalink)  
Old February 21st, 2010, 06:00 PM
Registered User
 
Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by chillbumps View Post
When I run the secret PIN version of the BasicUI app, it will not accept PIN entry. When I click on the pin buttons, the app crashes. My code builds and runs with no errors or warnings.
I also believe there's an error on page 66. Some of the code that needs to be entered is not in bold.
This book is already a bit outdated as the SDK no longer allows you to create outlets and actions in the way the book describes. I finally found the errata page. Its not the simplest to find as somehow I ended up on the ebook version first.

All this makes it difficult to flow through this book.

There was a PDF update by Wei-Meng about that issue with the outlets and actions. But even so, I found that the first example in chapter two (Hello World) didn't even work properly.
  #3 (permalink)  
Old July 29th, 2010, 04:32 AM
Registered User
 
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there,
I am going through this book too and it can be quite frustrating. I am struggling with the errata but seem to muddle around it. But learning a language with no mentor is usually frustrating.

On the subject of the buttons not acting.
I take ORIGINAL the code from btnClicked function and insert it in other sections to see if the code has got that far. Try it.

With the buttons not working and maybe the program stopping I found I had a spelling error. I had written "button" instead of "btn" in some examples. Check all your files and check what your buttons are calling.

I am only this far in the book and am far from being an expert but, I hope that is of help.
  #4 (permalink)  
Old July 29th, 2010, 04:42 AM
Registered User
 
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default My problem

I too have a problem in this section of the book.

In the BtnClicked function in its new "if" statment.
I get the warning - NSMutableString' may not respond to '-isEqualToString'
  #5 (permalink)  
Old December 22nd, 2010, 02:27 PM
Registered User
 
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Chapter 3 source code error

I´ve downloaded the source code for this example and it didnt worked for several reasons, the way I had it working was:

first I´ve changed the Base SDK in the "Project -> Edit Project Settings", "build" tab, "Base SDK" to Latest.

then I was able to publish it, but nothing was happening when I was clicking in the "Click me" button, the thing here is that the button in the interface builder was not linked to the File´s owner action btnClicked:

To solve that just double click in the BasicUIView.xib ;
click in the "click me" button to highlight it;
right click in the "click me" button and drag it to "File´s owner" icon,
when you release the button select "btnClicked:" event.

I hope I helped someone.

Best regards.

Dio
  #6 (permalink)  
Old June 24th, 2011, 02:14 AM
Registered User
 
Join Date: Jun 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by chillbumps View Post
When I run the secret PIN version of the BasicUI app, it will not accept PIN entry. When I click on the pin buttons, the app crashes. My code builds and runs with no errors or warnings.
I also believe there's an error on page 66. Some of the code that needs to be entered is not in bold.
This book is already a bit outdated as the SDK no longer allows you to create outlets and actions in the way the book describes. I finally found the errata page. Its not the simplest to find as somehow I ended up on the ebook version first.

All this makes it difficult to flow through this book.

Hi Chillbumps, I just saw your post after posting my concerns about the same subject If you managed to sort out the interface let me know
  #7 (permalink)  
Old June 24th, 2011, 08:19 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

If you post your viewController code someone should be able to sort out your problem. If the problem is not in the code, but rather in the IB connections, it will be necessary to actually see the project. You could send it to
ipadhelper@me.com
It would only take a minute or two to sort out.
The first thing I would do is compare your code to the download and check for discrepancies. There is an error in the download that needs to be fixed for it to run properly. The action method has not been connected to the Click Me button. This needs to be done for the alertView to actually show up.

Bob
  #8 (permalink)  
Old June 25th, 2011, 01:42 AM
Registered User
 
Join Date: Jun 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crashing Chapter 3 BasicUI

Hi Bob thanks for the quick reply and offer of support. I did swap the code which I hand set after struggling with a few typos. I switched it for the downloaded version of the basicUI m file in case I had missed something: Also Simulator 3.1.1. is what I am running. The app succeeds It is the linkage I think is the problem. Any further advice welcome. thanks for the interest.

[code]
#import "BasicUIViewController.h"

@implementation BasicUIViewController
@synthesize nameTextField;

- (IBAction)clearPinBtnClicked:(id)sender {
[secretPin setString:@""];
}

- (IBAction)pinBtnClicked:(id)sender {
[secretPin appendString:[sender titleForState:UIControlStateNormal]];
}

- (IBAction)btnClicked:(id)sender {
if ([secretPin isEqualToString: @"2345"]) {
NSString *str = [[NSString alloc] initWithFormat:@"Hello, %@", nameTextField.text ];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Hello"
message: str
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
[alert release];
[str release];
}
}


/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
secretPin = [[NSMutableString alloc] initWithCapacity:2];
[super viewDidLoad];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIIn terfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/


- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}


- (void)dealloc {
[nameTextField release];
[secretPin release];
[super dealloc];
}

@end[/quote]
  #9 (permalink)  
Old June 25th, 2011, 08:15 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

There is nothing wrong with the code you provided. You mentioned using Simulator 3.1.1, which version of Xcode are you using? One of the common user errors in the 3.x.x versions of Xcode is failure to save changes made in Interface Builder, particularly after connecting Outlets or Actions. This is also a common omission in the book, as it is sometimes included as a step, and sometimes not, so verify your connections. The alertView will only show up if the correct PIN number is entered, the nameTextField can be blank. To check secretPin value and to check the connection in the btnClicked:(id)sender method insert the following
Code:
- (IBAction)btnClicked:(id)sender {
	NSLog(@"In buttonClicked. The secretPin is %@", secretPin);
	if ([secretPin isEqualToString: @"2345"]) {
	    NSString *str = [[NSString alloc] initWithFormat:@"Hello, %@", nameTextField.text ];
    	UIAlertView *alert = [[UIAlertView alloc]
				 	        initWithTitle:@"Hello"  
					        message: str   
					        delegate:self  
					        cancelButtonTitle:@"OK" 
					        otherButtonTitles:nil, nil]; 
        [alert show]; 
        [alert release]; 
	    [str release];
	}
}
Run the project and see what the console log displays.

If you still have problems, send the project to the email in my last post, and I will track down the issue and set you on the right path.

Bob
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cr8 & Stored procedure ..Crash ..Crash swissaKM Crystal Reports 0 January 2nd, 2005 05:02 AM
Nested frames crash page when called on XP Umen Javascript 4 September 23rd, 2004 10:55 AM



All times are GMT -4. The time now is 02:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.