0
我有一個建立在Xcode中的應用,有一個按鈕註銷用戶,它包含下面的代碼,我有沒有問題:我的代碼不排隊因爲我想要
self.LbGoodBye.Text = @"Goodbye";
NSString *post =[[NSString alloc] initWithFormat:@"myQasidaName=%@",[self.textUserName text]];
NSLog(@"PostData: %@",post);
NSURL *url=[NSURL URLWithString:@"http:/MyWebSite/logOutUserDefaults.php"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error = [[NSError alloc] init];
NSHTTPURLResponse *response = nil;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"Response code: %ld", (long)[response statusCode]);
if ([response statusCode] >= 200 && [response statusCode] < 300) {
NSString *responseData = [[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"Response ==> %@", responseData);
NSString *url = [NSString stringWithFormat:@"http:/MyWebSite/logOutUserDefaults.php?qasidaName=%@",[self.textUserName text]];
NSData *data =[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
self.jasonArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
[self performSegueWithIdentifier:@"GoToMain" sender:self];
我有一個標籤,我想用它作爲向用戶說再見的信息,問題是當我把代碼放在乞討處,直到剩下的代碼完成時它才工作。
我不知道如果我有Xcode的一個問題,我試圖建立新的應用程序,但仍然有,我使用的Xcode 6.0.1同樣的問題,我開始建立使用Xcode的5
這個程序我是Xcode的新手,我沒有那麼多經驗來解決這個問題。
任何人都可以幫助我嗎?