私はiPhoneプログラミングが初めてです。
そのアレイをサーバーのファイルに追加し、サーバーのファイルを更新しNSMutableArray
たいものがあります。POST
php
xml
前もって感謝します。
私はiPhoneプログラミングが初めてです。
そのアレイをサーバーのファイルに追加し、サーバーのファイルを更新しNSMutableArray
たいものがあります。POST
php
xml
前もって感謝します。
このコードが必要な場合があります。
NSURLConnection * postConnectionの参照を.hで宣言し、それをプロパティにして.mファイルで合成します。
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"yourPhpUrl.php"]];
[request setHTTPMethod:@"POST"];
NSMutableDictionary *jsonDict = [[NSMutableDictionary alloc] init];
[jsonDict setValue:yourArray forKey:@"userName"];
NSLog(@"JSON Dict: %@",jsonDict);//Check your array here...
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"JSON String: %@",jsonString); //Check your post String here...
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"json" forHTTPHeaderField:@"Data-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [jsonData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: jsonData];
self.postConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:true];
これがあなたを助けるかもしれません