如何通知用户 iPhone 上 GET/POST 请求的结果?
我需要通知我的用户 GET 过程的结果,无论数据是否发送到服务器。谁能给我一个关于如何做的想法?
注意:在我的用户界面之一中有一些按钮,当用户单击它们时,一些数据将发送到服务器。我如何通知用户此请求的结果?谢谢..
编辑
-(IBAction)theAction:(id)sender{
NSString *key1=[[NSUserDefaults standardUserDefaults] valueForKey:@"keyToKey"];
NSString *userID=[[NSUserDefaults standardUserDefaults] valueForKey:@"userID"];
NSLog(@"\nButton ID: %d-",[sender tag] );
NSString *str1= [[@"http://" stringByAppendingString:serverF.text] stringByAppendingString:@"/request.php?"];
NSString *str2= [[str1 stringByAppendingString:@"key="] stringByAppendingString:key1];
NSString *str3= [[[[str2 stringByAppendingString:@"&userID="]stringByAppendingString:userID] stringByAppendingString:@"&button_tag="]stringByAppendingString:[ sender tag]];
NSURL *theUrl=[NSURL URLWithString:str3];
// What shall i do from here?, or is this way true???
}
现在我需要什么?
I need to inform my user about the result of the GET process whether the data is sent to server or not. Can anyone give me an idea about how to do?
Note: In one of my User Interfaces there are some buttons, and when the user clicks them some data will be sent to server. How can i inform user about this request's result? Thanks..
EDIT
-(IBAction)theAction:(id)sender{
NSString *key1=[[NSUserDefaults standardUserDefaults] valueForKey:@"keyToKey"];
NSString *userID=[[NSUserDefaults standardUserDefaults] valueForKey:@"userID"];
NSLog(@"\nButton ID: %d-",[sender tag] );
NSString *str1= [[@"http://" stringByAppendingString:serverF.text] stringByAppendingString:@"/request.php?"];
NSString *str2= [[str1 stringByAppendingString:@"key="] stringByAppendingString:key1];
NSString *str3= [[[[str2 stringByAppendingString:@"&userID="]stringByAppendingString:userID] stringByAppendingString:@"&button_tag="]stringByAppendingString:[ sender tag]];
NSURL *theUrl=[NSURL URLWithString:str3];
// What shall i do from here?, or is this way true???
}
What do i need from this point?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如何轻松地做到这一点的简单方法是使用 ASI HTTP。 http://allseeing-i.com/ASIHTTPRequest/How-to-use
那么您的请求的结果是:
如果您的请求成功完成,或者
如果失败。您可以根据需要选择队列、同步和异步请求。
Easy way how to do it comfortably is use ASI HTTP. http://allseeing-i.com/ASIHTTPRequest/How-to-use
Then result of your request is in:
in case your request finished successfuly, or
in case it failed. You can choose queue, sync and async requests, as you like.
您可以使用此单一方法获得相同的字符串:
You can get the same string with this single method:
在此代码中,您将在
GETresponse
处获得 GET HTTP 请求的结果:At this code you will have at the
GETresponse
the result for the GET HTTP request: