doc*_*606 2 cocoa-touch objective-c
我对iOS编程很新,但对它有基本的了解.我一直在使用Xcode 3进行精细编程,但是现在Xcode 4.2已经出局了,事情要困难得多(模板和所有模板都有变化).
现在我的问题:
我正在使用单页面应用程序
在我,ViewController.h我有这个:
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *Num1;
@property (weak, nonatomic) IBOutlet UITextField *Num2;
@property (weak, nonatomic) IBOutlet UILabel *answer;
- (IBAction)addNums:(id)sender;
Run Code Online (Sandbox Code Playgroud)
在我,ViewController.m我有这个:
- (IBAction)addNums:(id)sender
{
int x = ([Num1.text floatValue]);
int y = ([Num2.text floatValue]);
int ans = x + y;
answer.text = @"%i", ans;
}
Run Code Online (Sandbox Code Playgroud)
我已正确地将所有内容连接到文件所有者,但我不断收到此消息说"表达结果未使用".
再次,我很抱歉我的愚蠢问题,它只是我找不到任何Xcode 4.2在线教程,我找不到任何书籍.
而不是你的:
answer.text = @"%i", ans;
Run Code Online (Sandbox Code Playgroud)
做:
float x = ([Num1.text floatValue]);
float y = ([Num2.text floatValue]);
[answer setText:[NSString stringWithFormat:@"%i", x + y]];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13084 次 |
| 最近记录: |