gpt4 book ai didi

iphone - 将 Iphone 数据发送到 PHP NSUTF8StringEncoding

转载 作者:行者123 更新时间:2023-11-29 04:05:50 26 4
gpt4 key购买 nike

我正在按照在线视频教程将数据发送到 php 文件,然后将其存储在数据库中。

我真的很困惑埃文是如何工作的,因为没有帖子?它只是从变量中收集信息。我很少在 YouTube 上发表评论说同样的话,但他的工作原理是什么?

到目前为止我的代码...

- (IBAction)Submit:(id)sender {

NSString *strURL = [NSString stringWithFormat:@"http://www.bigwavemedia.co.uk/ios/contact.php?name=%@", nameField.text];

//to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];

NSString *strRes = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];

NSLog(@"%@", strRes);
}

当我点击提交按钮时,埃文虽然它已链接,但我没有得到任何回应?

最佳答案

在您的情况下,您需要创建 NSURLConnection用于与服务器通信。

NSString *strURL=[NSString stringWithFormat:@"http://www.bigwavemedia.co.uk/ios/contact.php?name=%@", nameField.text];

NSURL *url=[NSURL URLWithString:strURL];
self.request=[NSURLRequest requestWithURL:url];

self.nsCon=[[NSURLConnection alloc] initWithRequest:request delegate:self];

if(self.nsCon)
self.receivedData=[[NSMutableData alloc] init];
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error",@"") message:NSLocalizedString(@"Not Connected Other View !!",@"") delegate:nil cancelButtonTitle:NSLocalizedString(@"OK",@"") otherButtonTitles:nil];
[alert show];
[alert release];
}

Write 需要 NSURLConnection 的委托(delegate)方法,如上面的链接所述。

关于iphone - 将 Iphone 数据发送到 PHP NSUTF8StringEncoding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15249710/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com