내가 주석 처리 한 코드에서 몇 가지 오류가 있지만 해결 방법을 모릅니다. 너는 내가 그것을 고치기 위해 내가해야 할 일을 한 번 봐 주시겠습니까?식별자 오류 등
TIA
구현 파일
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize textField;
@synthesize label;
@synthesize userName = _userName;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setTextField:nil];
[self setLabel:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)changeGreeting:(id)sender {
self.userName = self.textField.text;
NSString *nameString = self.userName;
if ([nameString length] == 0)
nameString = @"World";
}
NSString *greeting = [[NSString alloc]initWithFormat:@"Hello, %@!", nameString]; // Use of undeclared identifier 'nameString'
self.label.text = greeting; // Unknown type 'self'
} // Expected external declaration
@end
인터페이스 파일 :
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UILabel *label;
- (IBAction)changeGreeting:(id)sender;
@property (copy, nonatomic)NSString *userName;
@end
힌트 들여다보기. 그리고 이전 줄에서 오류가있는 줄에서 찾을 수없는 오류가 발생하면 잘못된 줄이없는 경우 이전 줄로 다시 이동하십시오. 린스하고 반복하십시오. –
확인을 클릭하여 문제를 찾아 해결합니다. 고맙습니다! – pdenlinger