Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading 未使用AFNetworking代码调用NSURLConnectionLegate方法_Multithreading_Ios7_Afnetworking 2_Nsurlconnectiondelegate - Fatal编程技术网

Multithreading 未使用AFNetworking代码调用NSURLConnectionLegate方法

Multithreading 未使用AFNetworking代码调用NSURLConnectionLegate方法,multithreading,ios7,afnetworking-2,nsurlconnectiondelegate,Multithreading,Ios7,Afnetworking 2,Nsurlconnectiondelegate,我使用的是AFNetworking,代码运行良好,但在成功连接后,没有调用NSURLConnectionLegate方法的任何代理nethods 我在我的接口文件中也声明了NSURLConnection的委托。但似乎什么都不起作用,使用后台线程和主线程有什么问题吗? 这是我的密码: NSLog(@"\n\n1 Is main thread %@", ([NSThread isMainThread] ? @"Yes" : @" NOT")); AFHTTPRequestOperationMana

我使用的是AFNetworking,代码运行良好,但在成功连接后,没有调用NSURLConnectionLegate方法的任何代理nethods

我在我的接口文件中也声明了NSURLConnection的委托。但似乎什么都不起作用,使用后台线程和主线程有什么问题吗? 这是我的密码:

NSLog(@"\n\n1 Is main thread %@", ([NSThread isMainThread] ? @"Yes" : @" NOT"));

AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];

 manager.responseSerializer.acceptableContentTypes= [NSSet setWithObject:@"text/html"];





 NSDictionary *parameters = @{
                             @"email": [Constants sharedInstance].email,

                             @"password": [Constants sharedInstance].password,

                             };

 NSLog(@"\n\nparameters:   %@",parameters);



 [manager POST:@"https://anyurl/" parameters:parameters success:^

 (AFHTTPRequestOperation *operation, id responseObject) {


   //  [operation setRunLoopModes:[NSSet setWithObject:NSDefaultRunLoopMode]];

     NSLog(@"\n\n 2 Is main thread %@", ([NSThread isMainThread] ? @"Yes" : @" NOT"));


     [self stopLoading];

     NSLog(@"\n\nconnection successful!!");

    NSLog(@"\n\nJSON: %@", responseObject);

 }

      failure:^(AFHTTPRequestOperation *operation, NSError *error) {

 NSLog(@"\n\nError: %@", error);

 [self stopLoading];


 NSLog(@"Connection could not be made");

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Network" message:@"Cannot make connection to the server" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];

 [alert show];



      }
   ];

  NSLog(@"\n\n 3 Is main thread %@", ([NSThread isMainThread] ? @"Yes" : @" NOT"));

  [self startLoading];


  NSLog(@"\n\n4 Is main thread %@", ([NSThread isMainThread] ? @"Yes" : @" NOT"));

我看到了这一点,但无法使用该答案。

AFNetworking
是一个单独的库,如果您使用
AFNetworking
,它的成功和失败块将被执行。如果您想执行
nsurlconnectionelegate
方法,请使用
NSURLConnection
而不是
AFNetwork

thanx获取信息,但我想在成功连接时调用direceivedata之类的函数,那么如何调用它们呢?为什么所有这些相关帖子都是有效的呢?