我正在尝试通过 -JSON 代码从 TableWeb 中“选择”信息
在 xCode 中,当我“NSLog”时,它看起来像这样的信息:我试图摆脱那些符号 () []。我怎样才能只接收变量值?谢谢你们
2012-06-13 12:24:54.572 Gym31Vads[5628:16103] (
204
)
2012-06-13 12:33:33.911 Gym31Vads[5628:16103] (
204
)
2012-06-13 12:35:12.830 Gym31Vads[5628:16103] (
204
)
这是我在网上的 JASON 代码:
$var_email=$_POST['mail'];
$query = mysql_query(" SELECT `pk` FROM `adidas` WHERE `mail` = ('{$var_email}') LIMIT 1);
$users = array();
while ($row = mysql_fetch_array($query))
{
$users = array($row['pk']);
}
echo json_encode($users);
这是ObjectiveC代码:
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
NSString * urlString = [NSString stringWithFormat:@"myURLselectPK.php"];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSString*paramDataString=[NSString stringWithFormat:@"mail=%@",txt_mail.text];
NSData*paramData=[paramDataString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:paramData];
NSURLResponse *response;
NSError *error;
NSData *aData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSURL*url=[NSURL URLWithString:@"myURLselectPK.php"];
NSData*data=[NSData dataWithContentsOfURL:url];
NSError*err=nil;
NSMutableDictionary*jsondict=[NSJSONSerialization JSONObjectWithData:aData options:kNilOptions error:&err];
NSMutableArray*json=(NSMutableArray*)[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&err];
NSLog(@"%@",jsondict);
NSError *error2;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsondict
options:NSJSONWritingPrettyPrinted
error:&error2];
NSString*Str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString*str_screen=[NSString stringWithFormat:@"%@",Str];
lbl_pk_check.text=[NSString stringWithFormat:@"%@",Str];