Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kaydell.leavitt

macrumors regular
Original poster
Apr 19, 2010
100
0
Hi,

Will somebody help me to get an NSString from a UIText field?

This is what I'm guessing at, but I don't know where to look to see how to do this right.

Code:
#import <UIKit/UIKit.h>

@interface MarginCalcViewController : UIViewController {
	IBOutlet UITextField *costDisplay;
	IBOutlet UITextField *priceDisplay;
	IBOutlet UITextField *marginPercentDisplay;
}
- (IBAction) calculateCost;
- (IBAction) calculatePrice;
- (IBAction) calculateMarginPercent;
@end

... then, in the implementation, I have the following which doesn't work:

NSString string = [costDisplay textValue]; <<< warning, may not respond to -textValue


Thanks for taking the time to read my post.

-- Kaydell
 
Hi,

Will somebody help me to get an NSString from a UIText field?

This is what I'm guessing at, but I don't know where to look to see how to do this right.

#import <UIKit/UIKit.h>

@interface MarginCalcViewController : UIViewController {
IBOutlet UITextField *costDisplay;
IBOutlet UITextField *priceDisplay;
IBOutlet UITextField *marginPercentDisplay;
}
- (IBAction) calculateCost;
- (IBAction) calculatePrice;
- (IBAction) calculateMarginPercent;
@end

... then, in the implementation, I have the following which doesn't work:

NSString string = [costDisplay textValue]; <<< warning, may not respond to -textValue


Thanks for taking the time to read my post.

-- Kaydell :confused:



NSString *string = costDisplay.text;

Have you looked at the xcode help documentation, it has all the functions and parameters you can call on all the defined objects.
 
Thanks

Thanks for your help.

This is what is working for me now.

NSString *string = [costDisplay text];

-- Kaydell
 
Thanks for your help.

This is what is working for me now.

NSString *string = [costDisplay text];

-- Kaydell

if you @synthesize your iboutlets in your implementation you can use the dot notations

Code:
@synthesize costDisplay;
@synthesize priceDisplay;
@synthesize marginPercentDisplay;

and that would allow you to access them via

Code:
NSString *string = costDisplay.text;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.