hi i am writing a temperature converter program in objective c for i phone my code is given below i am getting an error “”error: incompatible type for argument 1 of ‘setText:”” please somebody help me to solve my problem
1. interface section
#import <UIKit/UIKit.h>
@interface farh_celcius_conv_AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UILabel *display;
IBOutlet UITextField *farhenite;
IBOutlet UIButton *convert;
float n ;
float k;
}
-(IBAction) convert;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UILabel *display;
@property (nonatomic, retain) IBOutlet UITextField *farhenite;
@property (nonatomic, retain) IBOutlet UIButton *convert;
@end
2. implementation section
#import "farh_celcius_conv_AppDelegate.h"
@implementation farh_celcius_conv_AppDelegate
@synthesize window,display,farhenite;
-(IBAction) convert {
NSString *str = [NSString txt];
float n = [str floatValue];
k = (n - 32)*(5/9);
[display setText: k];
// error:incompatible type for argument 1 of 'setText:
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
[window makeKeyAndVisible];
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
‘k’ is not a
NSString. Try this