错误:'setText 的参数 1 的类型不兼容:
你好,我正在为我的手机在 Objective C 中编写一个温度转换器程序,我的代码如下,我收到错误“”错误:'setText 的参数 1 的类型不兼容:“”请有人帮助我解决我的问题
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你可以尝试
也改变这条线吗
can you try
also change this line
试试这个,
因为 k 不是 NSString。
Try this,
Because, k is not a NSString.
'k' 不是
NSString
。试试这个'k' is not a
NSString
. Try this