好吧,我很难找到一个不只是使用JSON或ASIHTTPRequest的答案.但我认为我的问题更具体一些.我只是作为一个爱好编程,所以我不是专家.话虽如此,我对此的抽象理解可能完全偏离基础,所以这个问题可能无法回答.
基本上,我想要做的是向Web服务器上的pHp脚本发送HTTP请求,让Web服务器返回一个值,假设一个简单的整数值或bool值(想一个返回yes/no的登录脚本) ).我现在并不担心安全问题,因为我正试图让自己理解这一点.
从我收集的内容来看,我会使用一些东西来达到效果
// Create the request.
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData to hold the received data.
// receivedData is an instance variable declared elsewhere.
receivedData = [[NSMutableData data] retain];
} else {
// Inform the user that the connection failed.
}
Run Code Online (Sandbox Code Playgroud)
这是Apple的文档,我一般都明白这一点.所以我们假设它通过URL将信息发送到pHp文件,然后:
//pHp file gets information
//pHp file uses that information to …
Run Code Online (Sandbox Code Playgroud)