Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2011, 12:05 AM
Authorized User
 
Join Date: Mar 2011
Posts: 16
Thanks: 8
Thanked 0 Times in 0 Posts
Default Page 63 Coding the Action

Can anyone help a very confused newbee? Going blind trying to see where I have gone wrong..

Get this error: "no declaration of property 'nameTextField' found in the interface" @synthesize nameTextField

and

warning: no '-initWithTitle:message:delegate:cancelButtontitle:o therButtonTitles:' method found

at otherButtonTitles:nil, nil];

thanks in advance





Code:
#import "BasicUIViewController.h"

@implementation BasicUIViewController
@synthesize nameTextField;  



- (IBAction)btnClicked:(id)sender {
	
	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 {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // 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 {
    [super viewDidLoad];
}
*/


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

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


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

@end
 
Old April 5th, 2011, 07:31 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

It will be necessary to see your .h file as well, in order to try to provide a response.

Bob
 
Old April 5th, 2011, 10:18 PM
Authorized User
 
Join Date: Mar 2011
Posts: 16
Thanks: 8
Thanked 0 Times in 0 Posts
Thumbs up h Code

code as requested.

Code:

#import <UIKit/UIKit.h>

@interface BasicUIViewController : UIViewController {
    IBOutlet UITextField *nameTextField;
	IBOutlet UITextField *ageTextField;
}

@property (nonatomic, retain) UITextField *nameTextField;


- (IBAction)btnClicked:(id)sender;
@end
 
Old April 6th, 2011, 08:07 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

The problem in your Action method is a typo

Code:
- (IBAction)btnClicked:(id)sender {
	
	NSString *str = [[NSString alloc]
					 initWithFormat:@"Hello, %@", nameTextField.text ];
	UIAlertView *alert = [[UIAlertView alloc]
						initWithTitle:@"Hello"
						message: str
						delegate:self
						cancelButtontitle:@"OK" //is incorrect
						otherButtonTitles:nil, nil];  
	[alert show];
	[alert release];
	[str release];

						
						
}
should be

Code:
- (IBAction)btnClicked:(id)sender {
	
	NSString *str = [[NSString alloc]
					 initWithFormat:@"Hello, %@", nameTextField.text ];
	UIAlertView *alert = [[UIAlertView alloc]
						initWithTitle:@"Hello"
						message: str
						delegate:self
						cancelButtonTitle:@"OK" //is correct - the word Title is capitalized
						otherButtonTitles:nil, nil];  
	[alert show];
	[alert release];
	[str release];

						
						
}
All method names have the argument names in camelCase. If you manually type in the methods watch for this. Whenever possible let autofill do its thing.

From your supplied code I don't see the issue with the @property. If you have not yet resolved it an you still need help send the project to
iPadHelper@me.com
It is possible the error is caused somewhere else, so having the complete project will make it easier to track down.

Bob
The Following User Says Thank You to thepianoguy For This Useful Post:
Jule (April 6th, 2011)
 
Old April 6th, 2011, 08:44 AM
Authorized User
 
Join Date: Mar 2011
Posts: 16
Thanks: 8
Thanked 0 Times in 0 Posts
Default

Thank you, thank you, thank you. That was it, one typo, that I couldn't see.

it works.

Fresh eyes was what I needed.

Found out about the autocomplete by accident, and will use from now on as it makes things so much easier.

Once again thank you so very much.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Eratta: Chapter 2, Page 63 drupalmeister BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 2 March 23rd, 2010 07:39 AM
access C#.Net page as action of calssic ASP page mansharma_s ASP.NET 1.x and 2.0 Application Design 6 January 7th, 2008 10:58 AM
Refreshing a page based on action in pop-up nkrust ASP.NET 1.0 and 1.1 Basics 4 January 15th, 2007 04:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.