我正在學習如何編寫iOS應用程序並正在學習Objective-C。我試圖採取一個有7個字段的表單並將其發佈到我的網絡服務器。我已經有了不張貼代碼,我只需要所有的文本輸入字段連接成一個NSString
在iOS中發佈表單數據
文本輸入字段在.h
文件命名如下:
ctName
ctAddress1
ctAddress2
ctCity
ctState
ctZIP ctPhone
任何幫助將是非常讚賞。
UPDATE
所以,我已經想通了,但我不能回答我的問題了幾個小時......這是我想出了。這可能不是最有效的方式,但我已經測試過它並且工作正常。
NSString *body = [NSString stringWithFormat:@"stripeToken=%@", token.tokenId];
body = [body stringByAppendingString:@"&ctname="];
body = [body stringByAppendingString:self.ctName.text];
body = [body stringByAppendingString:@"&ctadd1="];
body = [body stringByAppendingString:self.ctAddress1.text];
body = [body stringByAppendingString:@"&ctadd2="];
body = [body stringByAppendingString:self.ctAddress2.text];
body = [body stringByAppendingString:@"&ctcity="];
body = [body stringByAppendingString:self.ctCity.text];
body = [body stringByAppendingString:@"&ctstate="];
body = [body stringByAppendingString:self.ctState.text];
body = [body stringByAppendingString:@"&ctzip="];
body = [body stringByAppendingString:self.ctZIP.text];
body = [body stringByAppendingString:@"&ctphone="];
body = [body stringByAppendingString:self.ctPhone.text];
由於問題是在串聯看看:http://stackoverflow.com/questions/8853865/simple-string-concatenation-in-objective-c –