ios - Xcode 4.6.3 中的解析问题 - "Expected a type"- 找不到错误

标签 ios objective-c xcode

Xcode 有问题:

目前我正在为 iOS SDK 6.1 开发一个应用程序。前几天我正在实现一些方法并尝试编译项目。 然后奇怪的事情发生了:

编译失败,我在两个文件中遇到了一些错误(见下图),这与我使用的方法无关。

我搜索了我的代码中的错误,但找不到任何错误。
然后我关闭项目再打开:他们还在这里。
然后我关闭项目和 Xcode,然后重新打开它们:它们还在这里。
然后我新建了一个项目,把所有的代码都复制过来: 问题又出现了。

现在我被困住了,不知道该怎么办。我是否遗漏了我的代码中的某些内容?

请帮帮我!

---

编辑 1:

这里有一些代码片段,在我遵循 Martin R 的建议后应该显示我的代码:

//  PlayingCardDeck.h  
@class PlayingCard;  
@interface PlayingCardDeck : NSObject  
- (void) addCard: (PlayingCard *) card atTop: (BOOL) atTop;  
- (PlayingCard *) drawRandomCard;  
- (BOOL) containsCard: (PlayingCard *) card;  
- (BOOL) isCardUsed: (PlayingCard *) card;  
- (void) drawSpecificCard: (PlayingCard *) card;  
- (void) reset;  
@end  

//  PlayingCardDeck.m  
#import "PlayingCardDeck.h"  
@interface PlayingCardDeck()  

//  PlayingCard.h  
#import <Foundation/Foundation.h>  
#import "RobinsConstants.h"  
#import "PlayingCardDeck.h"  
//@class PlayingCardDeck;  
@interface PlayingCard :  NSObject  
+ (NSArray*) suitStrings;  
+ (NSArray*) rankStrings;  
+ (NSUInteger) maxRank;  
- (id)initCardWithRank: (NSUInteger) r andSuit: (NSString*) s;  
- (NSString*) description;  
- (NSUInteger) pokerEvalRankWithDeck: (PlayingCardDeck *) deck;  
- (NSAttributedString *) attributedContents;  
- (BOOL) isEqual:(PlayingCard*)object;  
@property (strong, nonatomic) NSString *contents;  
@property (nonatomic, getter = isUsed) BOOL used;  
@property (nonatomic, readonly) NSInteger rank;
@property (nonatomic, readonly, strong) NSString * suit;  
@end

//  PlayingCard.m  
#import "PlayingCard.h"  
@interface  PlayingCard()

最佳答案

这看起来像一个典型的“导入周期”:

 // In PlayingCardDeck.h:
 @import "PlayingCard.h"

 // In PlayingCard.h:
 @import "PlayingCardDeck.h"

@class 替换其中一个 @import 语句应该可以解决问题,例如

 // In PlayingCardDeck.h:
 @class PlayingCard; // instead of @import "PlayingCard.h"

并且在实现文件中你必须导入完整的接口(interface):

 // In PlayingCardDeck.m:
 #import "PlayingCardDeck.h"  
 #import "PlayingCard.h"    // <-- add this one

关于ios - Xcode 4.6.3 中的解析问题 - "Expected a type"- 找不到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18673542/

相关文章:

ios - NSLocalNotification 重复。开除。合适的方式

ios - 为什么我的 UIButton 没有显示在我的 subview 中? iPad应用程式

iphone - 将 key 和证书复制到另一台 Mac 以进行 iPhone 开发

ios - 收到通知后我想更改我的 uiwebview

iphone - 在 UITableView 中对大量行/节进行动画处理性能不佳

objective-c - Objective C NSString 验证

ios - 从 AppDelegate 调用的 UIViewController 中的方法不使用现有对象

ios - 在 UIWebView 中不断丢失 php session cookie

ios - 如何从 Xcode 5 复制目标?

ios - 无法让 UITextField 自动缩小字体