2014-10-28 43 views
-2

我在我的Xcode应用程序中有一个TextField。现在我需要从ashx页面获得一个值。当我在浏览器中打开该ashx页面时,我可以看到它只显示一个值。我需要在TextField中显示该值。如何从ashx页面获取Xcode中的字符串值?

这是ashx的页面: somelink/Export.ashx F = GetClientBalance &销= rsbtest & includeCurrency =真

请帮我...

+0

我急需。我很抱歉,因为我对xCode编程很陌生。请回答如果有人知道这一点。 – Shoaib 2014-11-03 08:14:57

回答

0

您可以使用NSURLConnection的获得字符串数据。这里是代码:

NSURLResponse *response; 
NSError *error; 
NSData *data = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://rsbtelemax.com/VSServices/Export.ashx?f=GetClientBalance&pin=rsbtest&includeCurrency=true"]] returningResponse:&response error:&error]; 
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 
NSLog(error.description); 
NSLog(string); 
+0

我没有得到值...字符串值为空... – Shoaib 2014-11-05 13:12:25

+0

真的吗?它为我返回7.4003美元。你能发布你的代码吗? – sahara108 2014-11-06 01:45:49

+0

NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@“http://rsbtelemax.com/VSServices/Export.ashx?f=GetClientBalance&pin=rsbtest&includeCurrency=true”]]; NSString * strBal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; lblBalance.text = strBal; – Shoaib 2014-11-06 05:47:44

0

在HTML可以帮助吗? < IFRAME> 例如:

<!DOCTYPE html> 
<html> 
<body> 

<iframe frameborder="0" width="100%" height="50px" src="http://rsbtelemax.com/VSServices/Export.ashx?f=GetClientBalance&pin=rsbtest&includeCurrency=true" name="iframe_a"></iframe> 
<p><a href="http://www.w3schools.com" target="iframe_a">W3Schools.com</a></p> 

<p>When the target of a link matches the name of an iframe, the link will open in the iframe.</p> 

</body> 
</html> 
+0

用户已经在ashx中寻求帮助而不是在html中! – Hamad 2014-11-05 09:28:54

相关问题