ASIHTTPRequest e userInfo
-
23-09-2019 - |
Domanda
Secondo il sito web per ASIHTTPRequest:
Se le vostre richieste sono tutti dello stesso grande categoria, ma si vuole distinguere tra loro, è possibile impostare la proprietà userInfo NSDictionary di ogni richiesta con i propri dati personalizzati che si può leggere nel vostro finito / metodi delegato non riuscita.
Come faccio a impostare userInfo?
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
Soluzione
request.userInfo = [NSDictionary dictionaryWithObjectsAndKeys: dataObject, key, nil];
Altri suggerimenti
request.userInfo = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"init", @"operation", nil];
altrimenti otterrete un errore del tipo: metodo mutando inviato a objectt immutabili
Se si preferisce staffe al notazione del punto:
[request setUserInfo:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"init", @"operation", nil]];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow