나는 사전의 배열 인 PLIST에서 데이터를 표시하기 위해 노력하고있어 : 세포의 데이터를 표시 단지 벌금 rootviewcontroller에서plist에서 detailviewcontroller의 데이터를로드 하시겠습니까?
<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에 대해 동일하지 않습니까? ................... 편집 : 나는 그것을 알아 냈다 a를 tableviewcontroller에서 문자열을 만들어 다음 detailviewcontroller 등의
NSString *selectedItem = [arrayIndex objectAtIndex:indexPath.row];
detailViewController.selectedItem = selectedItem;
및로드 된 데이터를 이 :
coverImageView.image = [UIImage imageNamed:[selectedItem valueForKey:@"coverImage"]];
titleLabel.text = [selectedItem valueForKey:@"title"];
"details"사전에 무엇을 얻고 있는지 말해주십시오. ...... – objectivecdeveloper