将变量从Web视图传递到Xcode并存储为NSString

时间:2012-09-13 08:25:21

标签: php ios xcode webview nsstring

我正在尝试从Web视图填写的表单中传递变量,并将其存储为Xcode中的NSString。我有一个注册页面,将变量存储为cookie。然后在另一个页面中,我试图将该cookie作为变量返回并将其返回给Xcode。我认为我非常接近,但我需要一些帮助。

Xcode中:

NSString *strURL = [NSString stringWithFormat:@"http://www.website.com/get_id.php"];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];

NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];

UIAlertView *alert = [[UIAlertView alloc] 
                       initWithTitle:@"Your ID" 
                       message:strResult 
                       delegate:self 
                       cancelButtonTitle:@"Dismiss" 
                       otherButtonTitles:nil, nil];
[alert show];
return;

PHP:

<?php

$result = action($a, $b);
echo $result;

function action($a, $b){
    $your_email = $_COOKIE["your_email"];
    return $your_email;
}

?>

非常感谢您的时间和帮助!

0 个答案:

没有答案