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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 5th, 2011, 12:05 AM
Authorized User
Points: 62, Level: 1
Points: 62, Level: 1 Points: 62, Level: 1 Points: 62, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old April 5th, 2011, 07:31 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: 7%
Activity: 7% Activity: 7% Activity: 7%
 
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
Reply With Quote
  #3 (permalink)  
Old April 5th, 2011, 10:18 PM
Authorized User
Points: 62, Level: 1
Points: 62, Level: 1 Points: 62, Level: 1 Points: 62, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #4 (permalink)  
Old April 6th, 2011, 08:07 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: 7%
Activity: 7% Activity: 7% Activity: 7%
 
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
Reply With Quote
The Following User Says Thank You to thepianoguy For This Useful Post:
Jule (April 6th, 2011)
  #5 (permalink)  
Old April 6th, 2011, 08:44 AM
Authorized User
Points: 62, Level: 1
Points: 62, Level: 1 Points: 62, Level: 1 Points: 62, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
Reply


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
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 09:58 AM
Refreshing a page based on action in pop-up nkrust ASP.NET 1.0 and 1.1 Basics 4 January 15th, 2007 03:21 PM



All times are GMT -4. The time now is 03:51 AM.


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