[英]Expected identifier or '(' error before @class
我有這兩個課程:
ViewController.h
#import <UIKit/UIKit.h>
#import "UICustomButton.h"
@interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>{
...
ViewController.m
#import "ViewController.h"
@implementation ViewController
...
UICustomButton.h
#import <UIKit/UIKit.h>
@class ViewController;
@interface UICustomButton : UIButton{
...
UICustomButton.m
#import "UICustomButton.h"
#import "ViewController.h"
@implementation UICustomButton
...
我得到以下錯誤
1預期的標識符或'('-在@class之前的UICustomButton.h文件中
2預期為')'-也有
3預期的類型-當我嘗試在UICustomButton.h中使用ViewController時
4在UiCustomButton.m中我也收到錯誤
經過兩個小時的谷歌搜索和嘗試,我只是看不到問題所在。 你能幫忙嗎?
解決方案:重寫所有內容都是一個很好的想法。 它使我看到在文件ViewController.m中,我不小心在文件開頭的頂部鍵入了一個括號'('。編譯器沒有將其退出,只有UICustomButton.H生成錯誤。
看來您在拼錯ViewController.h。 #import行中有Viewcontroller.h
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.