How can I send multiple url request from a NSURLConnection delegate?

后端 未结 3 1196
天涯浪人
天涯浪人 2021-02-10 17:51

This is the logical flow for my application:

  1. At first, when the view controller has finished loading, then a NSURLConnection request can start its

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-10 18:29

    I do this with the NSURLConnection Making them properties, then checking which one it is:

     @property (nonatomic,retain) NSURLConnection *myConnection;
    @property (nonatomic,retain) NSURLConnection *mySecondConnection;
    

    then in the delegate:

    - (void)connectionDidFinishLoading:(NSURLConnection *)connection{
    
         if (connection == myConnection){
           //do something
        }
    
        if (connection == mySecondConnection){
           // do something else
            }
    
    }
    

    You can pass your NSURLRequest to the connection:

    self.myConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    

提交回复
热议问题