私は人々がそこに名前を入れることができる名前フィールドを作ろうとしています、そしてそれはphpページに送られます。
私はこのコードでスペースなしでこれを動作させました...
- (IBAction)Submit:(id)sender {
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:self.request delegate:self];
NSLog(@"out put = %@", self.request);
}
しかし、スペースアダーフィックスを使用するとすぐに、ログに機能していると表示されていても、phpページで取得されません。
- (IBAction)Submit:(id)sender {
NSString *strURL=[NSString stringWithFormat:@"http://www.bigwavemedia.co.uk/ios/contact.php?name=", nameField.text];
strURL = [strURL stringByAppendingString:nameField.text];
strURL = [strURL stringByAppendingString:@"'"];
strURL = [strURL stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSURL *url=[NSURL URLWithString:strURL];
self.request=[NSURLRequest requestWithURL:url];
self.nsCon=[[NSURLConnection alloc] initWithRequest:self.request delegate:self];
NSLog(@"out put = %@", self.request);
}
構文エラーが発生したり、このメソッドに間違った方法でアプローチしたりしましたか?
私の.hファイル
#import <UIKit/UIKit.h>
@interface ContactViewController : UIViewController <UITextFieldDelegate, UITextViewDelegate, NSURLConnectionDataDelegate>{
IBOutlet UITextField *nameField;
}
- (IBAction)Submit:(id)sender;
@property (nonatomic, retain) IBOutlet UITextField *nameField;
@property (strong) NSURLConnection *nsCon;
@property (strong) NSURLConnection *request;
@property (strong) NSURLConnection *receivedData;
@end
ありがとう