这是我的代码包含在一个函数中(当用户按下我创建的“登录”按钮时调用它).注意:变量’email’和’password’设置为我也创建的2个文本字段中的值.
NSURL *url = [NSURL URLWithString:@"http://mydomain.com/login-ipad/"];NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];Nsstring *messageBody = [Nsstring stringWithFormat:@"email=%@&user_pass=%@",email,password];Nsstring *msgLength = [Nsstring stringWithFormat:@"%d",[messageBody length]];[theRequest addValue: @"text/xml; charset=utf-8" forhttpheaderFIEld:@"Content-Type"];[theRequest sethttpMethod:@"POST"];[theRequest addValue: msgLength forhttpheaderFIEld:@"Content-Length"];[theRequest setValue:@"application/x-www-form-urlencoded" forhttpheaderFIEld:@"Current-Type"];[theRequest sethttpBody:[messageBody dataUsingEnCoding:NSUTF8StringEnCoding]];NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];if(theConnection){ NSLog(@"Connection Successful"); parent.loginbutton.enabled = NO; receivedData = [[NSMutableData data] retain];}else{ UIAlertVIEw *alert1 = [[[UIAlertVIEw alloc] initWithTitle:@"Alert" message:@"There was an issue sending the data. Please check your internet connection." delegate:self cancelbuttonTitle:@"OK" otherbuttonTitles:nil] autorelease]; [alert1 show];}
任何人都可以看到我的逻辑有什么问题?
解决方法 您正在添加Current-Type标头(AFAIK甚至不是有效标头)而不是Content-Type. 总结以上是内存溢出为你收集整理的在Objective-C iPad开发中发布全部内容,希望文章能够帮你解决在Objective-C iPad开发中发布所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)