'NSInvalidArgumentException', motivo: '- [SBJsonParser objectWithString: errore:]: selettore non riconosciuto inviato ad esempio 0x6695330'

StackOverflow https://stackoverflow.com/questions/8804642

  •  26-10-2019
  •  | 
  •  

Domanda

Durante la creazione di una vista di login sul mio iPhone app, mi sono imbattuto in questo errore:

'NSInvalidArgumentException', reason: '-[SBJsonParser objectWithString:error:]:
    unrecognized selector sent to instance 0x6695330'

E 'venuta da questa linea:

NSDictionary *results = [parser objectWithString:json_string error:nil];

Da questo metodo:

+ (BOOL)loginWithUsername:(NSString *)username password:(NSString *)password
{
    NSString *urlString = [NSString stringWithFormat:@"%@login3", ROSE_ROOT_URL];
    NSURL *url = [NSURL URLWithString:urlString];


    NSString *requestString = [NSString stringWithFormat:@"&mobile=1&username=%@&password=%@", username, password];


    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
    [request setHTTPMethod:@"POST"];
    [request setHTTPBody:[NSData dataWithBytes:[requestString UTF8String] length:[requestString length]]];

    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];

    [request release];
    // parse the JSON response into an object
    // Here we're using NSArray since we're parsing an array of JSON product objects
    SBJsonParser *parser = [[SBJsonParser alloc] init];
    NSDictionary *results = [parser objectWithString:json_string error:nil];

    [json_string release];
    [parser release];


    //  NSDictionary *results = [RoseFetcher fetch:request]; 
    //  [request release];

    if ([[results objectForKey:@"password"] intValue] == 0)
        return NO;

    return YES;
}

Qualsiasi aiuto o spiegazione sarebbe molto apprezzato.

È stato utile?

Soluzione

Secondo il documentazione per SBJsonParser , esso doesn' t hanno un metodo chiamato -objectWithString:error: - un parere che è corroborata da vostri risultati in fase di esecuzione. Provare a inviare un messaggio che rispondere, come -objectWithString:.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top