0

以下で何が間違っているのかを理解しようとして、私は絶対に夢中になります。いくつかの計算に応じて 0 または 1 をエコーする PHP ファイルがあります。結果が 0 の場合、アラートを 1 つ表示したいと思います。結果が 1 の場合は、別のアラートを表示したいと考えています。

奇妙なことに、PHP ファイル (aroundURLString以下の名前) から返された文字列をアラートに含めると、正しく表示されます。(これが意味するのは、アラートの「メッセージ」フィールドが機能しており、PHP ファイルが正しい値を返していることを証明しているということです....)

ただし、私の問題は、if ステートメントが期待どおりに機能しないことです。ここで私が間違っていることを誰かが知っていますか? 私はこれを理解しようとして夢中になっています。ありがとうございました!

    NSData *aroundURLResult = [NSData dataWithContentsOfURL:[NSURL 
    URLWithString:aroundURL]];

    // to receive the returend value
    NSString *aroundURLString = [[NSString alloc] initWithData:aroundURLResult 
    encoding:NSUTF8StringEncoding];

    if ([aroundURLString isEqualToString:@"0"]) {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"the string is 0" 
        message:aroundURLString delegate:self cancelButtonTitle:@"OK" 
        otherButtonTitles:nil, nil];
        [alert show];
        return;
    }

    if ([aroundURLString isEqualToString:@"1"]) {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"the string is 1" 
        message:aroundURLString delegate:self cancelButtonTitle:@"OK" 
        otherButtonTitles:nil, nil];
        [alert show];
        return;
    }
4

0 に答える 0