2013-12-11 62 views

回答

0
//Create the request 

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"your script name.php"]]; 
// create the Method "GET" or "POST" 

[request setHTTPMethod:@"POST"]; 

    //Pass The String to server 
NSString *userUpdate =[NSString stringWithFormat:@"artist_email=%@ ",your string Name,nil]; 

//Check The Value what we passed 
NSLog(@"the data Details is =%@", userUpdate); 

//Convert the String to Data 
NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding]; 

//Apply the data to the body 
[request setHTTPBody:data1]; 

//Create the response and Error 

NSError *err; 
NSURLResponse *response; 

NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err]; 

NSString *resSrt = [[NSString alloc]initWithData:responseData encoding:NSASCIIStringEncoding]; 

//This is for Response 
NSLog(@"got response==%@", resSrt); 

if(resSrt) 
{ 
    NSLog(@"got response"); 


} 
else 
{ 
    NSLog(@"faield to connect"); 
} 
0

我會建議使用它同時支持JSON和XML的開箱和發展,是因爲你不必JSON數據的解析管理,並從C#對象相對簡單的ASP.NET Web API,你可以那麼只需使用Entity Framework與數據庫進行通信即可。

開始:http://www.asp.net/web-api/overview/creating-web-apis/creating-a-web-api-that-supports-crud-operations

和:http://www.entityframeworktutorial.net/EntityFramework4.3/Introduction.aspx我覺得這是一個有點過時,但核心將保持不變