メインのviewControllerのファイルにNSMutableDictionary
called*temp
を作成し、このコードを追加してファイルから情報を取り込みました。.h
.plist
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"];
temp=[NSMutableDictionary dictionaryWithContentsOfFile:path];
}
同じビュー コントローラーで、ボタン アクションを追加し、次のコードを追加しました。
-(IBAction)mathButton:(UIButton *)_sender
{
label1.text = [temp objectForKey:@"m1name"];
}
ここで、「label1 は のテキスト フィールドであり.xib
、m1name
のキーの 1 つです。.plist
しかし、実行すると機能せず、強調表示されlabel1.text = [temp objectForKey:@"m1name"];
てアクセス不良と呼ばれます。
私はこれに数日間立ち往生しており、多くのことを試しました。答えは本当に役に立ちます。
ありがとう