我使用从 .m 文件中的按钮单击事件中复制的代码创建了一个自定义函数,如下所示。代码运行良好,直到我将它复制到我的 displayDev 函数中。这段代码的最后三行给了我一个“使用未声明的标识符”错误。有人能帮我弄清楚为什么 fullVerseLabel.text、VerseField.text 和 InterpretationField.text 都显示为未声明的标识符吗?下面也是我声明这些 UI 字段的 .h 代码。
您可以提供的任何帮助将不胜感激。非常感谢!
void displayDev (NSInteger dayNum)
{ NSString *plistFile = [[NSBundle mainBundle] pathForResource:@"Property List" ofType:@"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:plistFile];
NSString *bookString = [[dict objectForKey:[NSString stringWithFormat:@"Day %d", dayNum]] objectForKey:@"Book"];
NSString *chapterString = [[dict objectForKey:[NSString stringWithFormat:@"Day %d", dayNum]] objectForKey:@"Chapter#"];
NSString *verseString = [[dict objectForKey:[NSString stringWithFormat:@"Day %d", dayNum]] objectForKey:@"Verse#"];
NSString *fullVerseString = [bookString stringByAppendingString:@" "];
fullVerseString = [fullVerseString stringByAppendingString:chapterString];
fullVerseString = [fullVerseString stringByAppendingString:@":"];
fullVerseString = [fullVerseString stringByAppendingString:verseString];
fullVerseLabel.text = fullVerseString;
VerseField.text = [dict objectForKey:[NSString stringWithFormat:@"Day %d", dayNum]objectForKey:@"Verse"];
InterpretationField.text = [dict objectForKey:[NSString stringWithFormat:@"Day %d", dayNum] objectForKey:@"Interpretation"];
currentlyViewing = dayNum;
}
我在我的 .h 文件中声明了变量并链接到我的故事板。
@interface FirstViewController : UIViewController
{ IBOutlet UILabel *fullVerseLabel;
IBOutlet UITextView *VerseField;
IBOutlet UITextView *InterpretationField;
IBOutlet UITextField *TextField;
}