开发者

ASIHTTPRequest and userInfo

开发者 https://www.devze.com 2022-12-21 14:17 出处:网络
According to the website for ASIHTTPRequest: If your requests are all of the same broad type, but you want to

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]];
0

精彩评论

暂无评论...
验证码 换一张
取 消