2014-10-28 45 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

相關問題