0

これまでのところ、私はこれを持っています:

Web ページから hpple を使用して日付を解析し、ラベルに表示しようとしています。どうすればいいのかわかりません。void GoToSecretsList の Secret 変数を、他の void が取得している値と何らかの形で等しくする必要があると思います...誰か提案はありますか?

- (void)GoToSecretsList
{
UIViewController *vc;

vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecretsListID"];
[self.navigationController pushViewController:vc animated:YES];

UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 120, 500, 40)];
[myLabel setBackgroundColor:[UIColor clearColor]];

NSString *Secret;
Secret = @"Get value from website";

[myLabel setText:[NSString stringWithFormat:@"#1: %@", Secret]];


[[vc view] addSubview:myLabel];

}

 -(void)LoadSecrets {
// 1
NSURL *SecretsUrl = [NSURL URLWithString:@"http:/removed.com/xlxlx"];
NSData *SecretsHtmlData = [NSData dataWithContentsOfURL:SecretsUrl];

// 2
TFHpple *secretsParser = [TFHpple hppleWithHTMLData:SecretsHtmlData];

// 3
NSString *secretsXpathQueryString = @"/secret";
NSArray *secretsNodes = [secretsParser searchWithXPathQuery:secretsXpathQueryString];

// 4
NSMutableArray *newSecrets = [[NSMutableArray alloc] initWithCapacity:0];
for (TFHppleElement *element in secretsNodes) {
    // 5
    VOI *secret = [[VOI alloc] init];
    [newSecrets addObject:secret];

    // 6
    secret.title = [[element firstChild] content];

    // 7
    secret.url = [element objectForKey:@"href"];
}

 }

編集:今、私はこれを持っています:

 - (void)GoToSecretsList
 {
UIViewController *vc;

vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecretsListID"];
[self.navigationController pushViewController:vc animated:YES];

UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 120, 500, 40)];
[myLabel setBackgroundColor:[UIColor clearColor]];


NSURL *SecretsUrl = [NSURL URLWithString:@"http://removed.com/dsdsds"];
NSData *SecretsHtmlData = [NSData dataWithContentsOfURL:SecretsUrl];


TFHpple *secretsParser = [TFHpple hppleWithHTMLData:SecretsHtmlData];


NSString *secretsXpathQueryString = @"/secret";
NSArray *secretsNodes = [secretsParser searchWithXPathQuery:secretsXpathQueryString];


[myLabel setText:[NSString stringWithFormat:@"#1: %@", secretsNodes]];
[[vc view] addSubview:myLabel];

}

しかし、どの変数が情報を持っています..? または私が間違っていることは何ですか?secretNodes はそうではないからです。

4

1 に答える 1