0
我使用从我的.m文件中的按钮单击事件复制的代码创建了如下所示的自定义函数。代码工作正常,直到我将它复制到我的displayDev函数。这段代码中的最后三行给了我一个“使用未声明的标识符”的错误。有人可以帮我弄清楚为什么fullVerseLabel.text,VerseField.text和InterpretationField.text都显示为未声明的标识符?下面是我的.h代码,我声明了这些UI字段。自定义函数中UI字段的未声明标识符
任何帮助,您可以提供将不胜感激。非常感谢!
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文件中声明的变量,并链接到我的故事板。随着该语法,你实际上宣告这是一个C函数,而不是Objective-C的
void displayDev (NSInteger dayNum)
:
@interface FirstViewController : UIViewController
{ IBOutlet UILabel *fullVerseLabel;
IBOutlet UITextView *VerseField;
IBOutlet UITextView *InterpretationField;
IBOutlet UITextField *TextField;
}
正是我所需要的。非常感谢! – iroosma