iphone 实行http post 及多线程编程实例
2010-03-31 17:30:00 来源:WEB开发网#import "FirstUIAppDelegate.h"
@implementation FirstUIAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
//[self postdata];
[self setupThread];
[window makeKeyAndVisible];
}
-(void)setupThread{
[NSThread detachNewThreadSelector:@selector(postdata)toTarget:self withObject:nil];
}
- (void)dealloc {
[window release];
[super dealloc];
}
-(void)postdata{
NSLog(@"TEST");
NSURL *url;
NSMutableURLRequest *urlRequest;
NSMutableData *postBody = [NSMutableData data];
url = [NSURL URLWithString:@"http://allove.org"];
urlRequest = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease];
[urlRequest setHTTPMethod:@"POST"];
NSString *udid = @"phong=15871485145&psw=23";
[postBody appendData:[udid dataUsingEncoding: NSUTF8StringEncoding allowLossyConversion:YES]];
[urlRequest setHTTPBody:postBody];
NSData *returnData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil];
if(returnData)
{
NSString *result = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];
NSLog(@"result=======>%@",result);
}
else
{
NSLog(@"Wrong Connetion!");
}
}
@end
- ››iphone图片拉伸的几种方法
- ››iphone正则表达式的简单使用
- ››HttpHandler生成随机码、验证码
- ››Http 403错误重现实验及解决方法
- ››iPhone开发Unresolved Symbols CAKeyframeAnimati...
- ››IPhone开发-“此证书是由未知颁发机构签名”解决方...
- ››IPhone开发-整合私钥和证书,生成.p12文件
- ››iPhone应用开发-UIPickerView选取器详解
- ››iphone 获取屏幕的宽度和高度
- ››iPhone读取工程包中的二进制文件
- ››iPhone新手机 不挂YouTube APP
- ››iPhone 获取指定格式的时间和日期
赞助商链接