synchronous request for login using a WebService

Discussion in 'iOS Programming' started by pecorrea, Jan 28, 2009.

  1. pecorrea macrumors newbie

    Joined:
    Dec 19, 2008
    #1
    Hi there,

    I ask for your help here, i'm having a trouble (maybe it's conceptual too). I'm using some webservices to get data, but first there's a webservice to login, that returns a sessionId when successful. I've been using the code from icodeblog's tutorial about SOAP web services (this one), but my problem is that i need this SOAP login thing to lock the application (like running on the main thread).

    I've tried the performSelectorOnMainThread method, but my class doesn't recognize my selector ("[MainData login:]: unrecognized selector sent to instance 0x529f60'"). My code is something like this:

    Code:
    - (void) init {
     // some code ...
    lg = [[LoginWebServiceData alloc] init];
    	[self performSelectorOnMainThread:@selector(login:) withObject:nil waitUntilDone:YES];
    // After login, we check what's on LoginWebServiceData's sessionId to see if there's a valid response
    	sessionId = lg.sessionId;
    }
    
    - (void)login {
    	[lg loginWithUsernameAndPassword:@"asdf" :@"asdf"];
    }
    Login is declared on the interface, so i don't know what's wrong ;( I think i can use the Synchronous request, but i think this is a better way to do this. Any ideas? :D
     
  2. jnic macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #2
    Your selector is login: but your method is just login (i.e. takes no arguments). You need to change your selector to match your method.
     
  3. pecorrea thread starter macrumors newbie

    Joined:
    Dec 19, 2008
    #3
    thanks jnic, now almost evrything is right. After testing my method to make synchronous SOAP, it doens't work :( looks like the Connection ([[NSURLConnection alloc] initWithRequest:theRequest delegate:self] ) runs on a different thread and i'll have to use "sendSynchronousRequest:returningResponse:error:", but i don't see a delegate there (the common request asks for a delegate). Does it have the same behavior as the asynchronous request? :eek:
     

Share This Page