NSMutableString *post = [NSString stringWithFormat:@"sTrainer_id=%@",[self.sUser_id description]]; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; NSURL *url = [NSURL URLWithString:@"http://localhost/APIclient_measurement.php"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self]; if (theConnection) { self.receivedData = [[NSMutableData data] retain]; } else { UIAlertView *connectFailMessage = [[UIAlertView alloc] initWithTitle:@"NSURLConnection " message:@"Failed in viewDidLoad" delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [connectFailMessage show]; [connectFailMessage release]; } NSMutableString *post1 = [NSString stringWithFormat:@"sTrainer_id=%@",[self.sUser_id description]]; NSData *postData1 = [post1 dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength1 = [NSString stringWithFormat:@"%d", [postData1 length]]; NSURL *url1 = [NSURL URLWithString:@"http://localhost/API/client_goals.php"]; NSMutableURLRequest *request1 = [NSMutableURLRequest requestWithURL:url1 cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0]; [request1 setHTTPMethod:@"POST"]; [request1 setValue:postLength1 forHTTPHeaderField:@"Content-Length"]; [request1 setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request1 setHTTPBody:postData1]; NSURLConnection *theConnection1=[[NSURLConnection alloc] initWithRequest:request1 delegate:self]; if (theConnection1) { self.receivedData1 = [[NSMutableData data] retain]; } else { UIAlertView *connectFailMessage = [[UIAlertView alloc] initWithTitle:@"NSURLConnection " message:@"Failed in viewDidLoad" delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [connectFailMessage show]; [connectFailMessage release]; }
Quote:APIclient_measurement.php
@property (nonatomic,retain) NSURLConnection *myConnection; @property (nonatomic,retain) NSURLConnection *mySecondConnection;
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{ if (connection == myConnection){ //do something } if (connection == mySecondConnection){ // do something else } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง