0

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

这是我的 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

这是我的 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

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

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

怎么了 ?

4

2 回答 2

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.

于 2013-04-24T04:16:42.333 回答
1

只需先删除它@end。这是完全错误的。您只能@end@implementation@interface@protocol声明之后。

于 2012-08-30T17:54:55.610 回答