ASIHTTPRequest and userInfo
According to the website for ASIHTTPRequest:
If your requests are all of the same broad type, but you want to distinguish between them, you can set the userInfo NSDictionary property of开发者_如何学运维 each request with your own custom data that you can read in your finished / failed delegate methods.
How do I set userInfo?
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
request.userInfo = [NSDictionary dictionaryWithObjectsAndKeys: dataObject, key, nil];
request.userInfo = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"init", @"operation", nil];
otherwise you will get an error like: mutating method sent to immutable objectt
If you prefer brackets to dot notation:
[request setUserInfo:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"init", @"operation", nil]];
精彩评论