objective-c – Xcode中的未知类型名称(即使使用@class声明)

前端之家收集整理的这篇文章主要介绍了objective-c – Xcode中的未知类型名称(即使使用@class声明)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在设置数据控制器的简单应用程序时遇到问题.我在@property(强,非原子)BirdsListDataController * dataController行上遇到错误;在BirdsListViewController.h中.我尽力使用BirdsListDataController的@class声明,并尝试从.h文件删除任何#import语句,并尝试删除一个循环#import,你可以在BirdsListViewController的顶部找到它. H.我猜它很简单.

BirdsListViewController.h

@H_403_13@#import <UIKit/UIKit.h> @class BirdsListDataController; @interface BirdsListViewController : UITableViewController <UITextFieldDelegate> { // NSMutableArray *listOfBirds; IBOutlet UITextField *addNewBirdTextField; } //@property (nonatomic,retain) NSIndexPath *checkedIndexPath; @property (nonatomic,retain) NSString *textLabelContents; @property (nonatomic,retain) NSMutableArray *workingArray; @property (strong,nonatomic) BirdsListDataController *dataController; @property (strong,nonatomic) IBOutlet UITableView *birdListTableView; @end

BirdsListViewController.m

@H_403_13@#import "BirdsListViewController.h" #import "BirdsListDataController.h" @interface BirdsListViewController () @end @implementation BirdsListViewController - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { ...

BirdsListDataController.h

@H_403_13@#import <Foundation/Foundation.h> @class BirdName; @interface BirdsListDataController : NSObject @property (nonatomic,copy) NSMutableArray *listOfBirds; -(NSUInteger)countOfList; -(BirdName *)objectInListAtIndex:(NSUInteger)theIndex; -(void)addBirdNameWithName:(BirdName *)bName; @end

BirdsListDataController.m

@H_403_13@#import "BirdsListDataController.h" //#import "BirdsListViewController.h" #import "Bird.h" @implementation BirdsListDataController -(id)init {...

我仍然是iOS和Objective C的新手,所以希望我的代码不是太难以排除故障.谢谢您的帮助.

解决方法

我不确定是什么导致了你的问题,但有一些事情:

>在您提供的代码中,没有理由不在BirdListViewController.h中导入BirdListDataController.h,因为在BirdListDataController.h中没有对BirdListViewControllers的引用.所以尝试用#import语句替换你的@class声明.>在BirdListDataController.h中声明@class BirdName,但在BirdListDataController.m中导入Bird.h而不是BirdName.h.看起来有些东西可能出错了,虽然我必须看到BirdName.h和Bird.h的代码才能确定.

猜你在找的Xcode相关文章