Ios Xcode 5多个错误#导入未导入头文件
我正在努力实现一个搜索栏,搜索一个表视图,我有很多错误 短语手册Ios Xcode 5多个错误#导入未导入头文件,ios,xcode,Ios,Xcode,我正在努力实现一个搜索栏,搜索一个表视图,我有很多错误 短语手册 #import <Foundation/Foundation.h> @interface Phrasebook : NSObject @property (nonatomic, strong) NSString *name; //name of phrase @property (nonatomic, strong) NSString *translation; //translation of name @en
#import <Foundation/Foundation.h>
@interface Phrasebook : NSObject
@property (nonatomic, strong) NSString *name; //name of phrase
@property (nonatomic, strong) NSString *translation; //translation of name
@end
词组
#import <UIKit/UIKit.h>
@interface PhrasebookTableCell : UITableViewCell
@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UILabel *translationLabel;
@end
有关.m文件的代码:
{
static NSString *CellIdentifier = @"CustomTableCell";
ERROR PhrasebookTableCell *cell = (PhrasebookTableCell *)[[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier]]; ERROR
// Configure the cell...
ERROR if (cell == nil) {
cell = [[PhrasebookTableCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier]; ERROR
}
// Display recipe in the table cell
ERROR Phrasebook *phrasebook = [Phrasebook objectAtIndex:indexPath.row];
cell.nameLabel.text = phrasebook.name;
cell.translationLabel.text = phrasebook.translation;
return cell; ERROR
}
错误:1) 分析问题:预期标识符
2) ARC语义问题:“PhrasebookTableCell”没有可见的@interface声明选择器“initWithStyle:reuseIdentifier:”
3) ARC语义问题:选择器“objectAtIndex:”没有已知的类方法
4) 语义问题:在“PhrasebookTableCell*”类型的对象上找不到属性“nameLabel”
5) 语义问题:在所讨论的.m文件第3行的“PhrasebookTableCell*”类型的对象上找不到属性“translationLabel”,当一个
[
就足够时,您有两个[
括号。请删除一个[
对,然后重试
像这样:
PhrasebookTableCell *cell = (PhrasebookTableCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
您可以标记哪些行出现错误吗?另外,您可以发布PhrasebookTableCell.h文件吗?什么是
PhraseBook
?自定义`NSArray?您是否尝试重新启动xcode并清理项目?3)看起来您是在类PhraseBook上调用objectAtIndex,而不是在NSArray实例上。标有开头的错误和结尾的错误是很麻烦的一行。Phrasebook只是一个类的名称,(视图应该是一本有用短语的书)。我已经清理了项目并多次重新启动xcode。ThanksRE:Larme,“Phrasebook”是在Phrasebook.h和Phrasebook.m文件中声明的NSObject
{
static NSString *CellIdentifier = @"CustomTableCell";
ERROR PhrasebookTableCell *cell = (PhrasebookTableCell *)[[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier]]; ERROR
// Configure the cell...
ERROR if (cell == nil) {
cell = [[PhrasebookTableCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier]; ERROR
}
// Display recipe in the table cell
ERROR Phrasebook *phrasebook = [Phrasebook objectAtIndex:indexPath.row];
cell.nameLabel.text = phrasebook.name;
cell.translationLabel.text = phrasebook.translation;
return cell; ERROR
}
PhrasebookTableCell *cell = (PhrasebookTableCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];