How to send and receive data to MySQL DB using PHP in Objective-C?

0

Scenario:  Sending and receiving forms to a MySQL database using PHP.

I would like to know if anyone knows or has any link to a tutorial course and clear about these procedures, sending and receiving using JSON.

It can be in English or Portuguese, and preference for asynchronous transfer.

    
asked by anonymous 15.10.2014 / 18:16

1 answer

0

The solution I found was this! I can send an argument to a php and it returns me the result of the query:

// FUNCIONA PODE SER USADO PARA ENVIAR OS ARGUEMENTOS E RECEBER O RETORNO DA QUERY DO PHP

    NSMutableString* strURL =[[NSMutableString alloc]initWithFormat:@"http://localhost/testesPHP/buscaFuncionarios.php?numero=%@",nomeCadastro.text];


    NSURL* url = [NSURL URLWithString: strURL];


    NSData* data = [NSData dataWithContentsOfURL:url];

    NSError*erro;

    NSMutableArray* oabsRecebidas;

// Recebe o retorno vindo do arquivo PHP buscaFuncionarios.php (no caso usando Json)
    oabsRecebidas = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&erro];

// Escreve na tela o retorno
    NSLog(@"%@", oabsRecebidas);
    
21.10.2014 / 21:03