@end必须出现在objective-c上下文中

时间:2021-04-24 11:34:29

I am Following a tutorial at http://www.raywenderlich.com/14172/how-to-parse-html-on-ios .

我正在http://www.raywenderlich.com/14172/how-to-parse-html-on-ios上阅读教程。

Here is my detailviewcontroller.h file.

这是我的detailviewcontroller.h文件。

#import <UIKit/UIKit.h>

    @end <-- //errors shows up here.

    @interface DetailViewController : UIViewController

    @property (strong, nonatomic) id detailItem;

    @property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
    @end

This is my detailview.m file

这是我的detailview.m文件

#import "DetailViewController.h"


@interface DetailViewController ()
- (void)configureView;
@end

@implementation DetailViewController

#pragma mark - Managing the detail item

- (void)setDetailItem:(id)newDetailItem
{
    if (_detailItem != newDetailItem) {
        _detailItem = newDetailItem;

        // Update the view.
        [self configureView];
    }
}

- (void)configureView
{
    // Update the user interface for the detail item.

    if (self.detailItem) {
        self.detailDescriptionLabel.text = [self.detailItem description];
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self configureView];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Detail", @"Detail");
    }
    return self;
}

@end

As i referred above, the @end error message appears and wait to auto fix in red square, the i agree to do the auto fix. Then the xCode applies the @end code over there, as shown in the .h file. Then an other error appears as which is in the title " @end must appear in an objective-c context "

正如我上面提到的,出现@end错误消息并等待自动修复红色方块,我同意进行自动修复。然后xCode在那里应用@end代码,如.h文件中所示。然后出现另一个错误,标题为“@end必须出现在objective-c上下文中”

what should i do ? Is xCode gone mad or what.

我该怎么办 ? xCode是疯了还是什么。

Whats wrong ?

怎么了 ?

2 个解决方案

#1


3  

In my case, somewhere along the line I missed a @end in one of the .h file. So all files that import that .h file is prompting this error. The funny thing is, I don't receive this error message on the one .h file that does miss the @end. So I guess you need to do some searching make sure you close all your @interface, @implementation or @protocol with @end. Hope that helps.

在我的情况下,沿着这条线的某个地方,我错过了一个.h文件中的@end。因此,导入该.h文件的所有文件都会提示此错误。有趣的是,我没有在错过@end的.h文件上收到此错误消息。所以我想你需要做一些搜索,确保你用@end关闭所有@interface,@ implementation或@protocol。希望有所帮助。

#2


0  

Just remove that first @end. It's completely wrong. You can only have @end after an @implementation, @interface, or @protocol declaration.

只需删除第一个@end。这是完全错误的。在@implementation,@ interface或@protocol声明之后,您只能拥有@end。

#1


3  

In my case, somewhere along the line I missed a @end in one of the .h file. So all files that import that .h file is prompting this error. The funny thing is, I don't receive this error message on the one .h file that does miss the @end. So I guess you need to do some searching make sure you close all your @interface, @implementation or @protocol with @end. Hope that helps.

在我的情况下,沿着这条线的某个地方,我错过了一个.h文件中的@end。因此,导入该.h文件的所有文件都会提示此错误。有趣的是,我没有在错过@end的.h文件上收到此错误消息。所以我想你需要做一些搜索,确保你用@end关闭所有@interface,@ implementation或@protocol。希望有所帮助。

#2


0  

Just remove that first @end. It's completely wrong. You can only have @end after an @implementation, @interface, or @protocol declaration.

只需删除第一个@end。这是完全错误的。在@implementation,@ interface或@protocol声明之后,您只能拥有@end。