xcode 执行不完整
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8334275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Incomplete implementation
提问by pdenlinger
I'm getting an incomplete implementation warning on my implementation page, which I have commented out:
我在我的实现页面上收到了一个不完整的实现警告,我已经注释掉了:
#import "BIDDatePickerViewController.h"
@implementation BIDDatePickerViewController // Incomplete implementation
@synthesize datePicker;
- (IBAction)buttonPressed:(id)sender
{
NSDate *selected = [datePicker date];
NSString *message = [[NSString alloc] initWithFormat:@"The date and time you selected is:%@", selected];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Date and Time Selected"
message:message
delegate:nil
cancelButtonTitle:@"Yes I did"
otherButtonTitles:nil];
[alert show];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSDate *now = [NSDate date];
[datePicker setDate:now animated:NO];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.datePicker = nil;
}
@end
Also the custom part of the message, showing date, time chosen is not showing up correctly. Why?
此外,消息的自定义部分(显示日期、所选时间)未正确显示。为什么?
Following is the interface file:
接口文件如下:
#import <UIKit/UIKit.h>
@interface BIDDatePickerViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIDatePicker *datePicker;
-(IBAction)buttonPressed;
@end
回答by Marc Charbonneau
The reason you're getting a warning is because you implemented the method - (IBAction)buttonPressed:(id)sender
, while you defined the method -(IBAction)buttonPressed;
. Note the lack of an argument on the interface.
您收到警告的原因是您- (IBAction)buttonPressed:(id)sender
在定义方法的同时实现了方法-(IBAction)buttonPressed;
。请注意接口上缺少参数。
回答by syclonefx
In your .h file you have - (IBAction)buttonPressed;
and in your .m file you have - (IBAction)buttonPressed:(id)sender
. You should have - (IBAction)buttonPressed;
in your .m file
在你的 .h 文件中你有- (IBAction)buttonPressed;
,在你的 .m 文件中你有- (IBAction)buttonPressed:(id)sender
. 你应该- (IBAction)buttonPressed;
在你的 .m 文件中