私は辞書の配列であるのplistからのデータを表示しようとしている:rootviewcontrollerで詳細ビューコントローラのデータをplistからロードしますか?
<array>
<dict>
<key>title</key>
<string>RATATOUILLE</string>
<key>coverImage</key>
<string>rat.png</string>
<key>smallImage</key>
<string>rat-small.png</string>
<key>description</key>
<string>Spray a pan with cooking spray. Brown the onion and the garlic (do not let garlic burn!). Add all the veggies and the bay leaf and simmer covered for 2 hours. Sprinkle on the breadcrumbs and cook another 5 minutes. Remove the bay leaf and serve.
5 servings, 0 POINTS each (if you eat the whole thing, count points for the bread crumbs)</string>
</dict>
データ表示は、細胞内でうまく。 detailviewcontrollerでは、私は同じメソッドを試しましたが、何も表示されません。私は間違って何をしていますか?私は理解していないものを
- (void)viewDidLoad {
[super viewDidLoad];
NSDictionary *details = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Testdata" ofType:@"plist"]];
coverImageView.image = [UIImage imageNamed:[details objectForKey:@"coverImage"]];
titleLabel.text = [details objectForKey:@"title"];
}
は、それが実際にどのように動作するかです: は、ここでは、コードです。 rootviewcontrollerでは、私はこのメソッドを持っています:
-(id)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"TestData" ofType:@"plist"];
arrayIndex = [[NSArray alloc] initWithContentsOfFile:path];
}
return self;
}
そしてデータは "arrayIndex"から引き出されます。 detailviewcontrollerのために同じではありませんか? ................... 編集:私は、それを考え出したtableviewcontroller内の文字列行わ :detailviewcontrollerなどに
NSString *selectedItem = [arrayIndex objectAtIndex:indexPath.row];
detailViewController.selectedItem = selectedItem;
とロードされたデータをこの:
coverImageView.image = [UIImage imageNamed:[selectedItem valueForKey:@"coverImage"]];
titleLabel.text = [selectedItem valueForKey:@"title"];
「詳細」辞書に何が入っているのか教えてください...... – objectivecdeveloper