【问题标题】:ASIHTTPRequest and userInfoASIHTTPRequest 和 userInfo
【发布时间】:2010-02-26 13:53:16
【问题描述】:

根据 ASIHTTPRequest 的网站:

如果您的要求都一样 广泛的类型,但你想 区分它们,可以设置 的 userInfo NSDictionary 属性 每个请求都有您自己的自定义数据 你可以在你完成的/ 委托方法失败。

如何设置用户信息?

NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:url];
[request setDelegate:self];
[request startAsynchronous];

【问题讨论】:

    标签: iphone set asihttprequest userinfo


    【解决方案1】:
    request.userInfo = [NSDictionary dictionaryWithObjectsAndKeys: dataObject, key, nil];
    

    【讨论】:

    • 我有一个 java 服务器并设置了 UserInfo,我可以在服务器端获取该 userInfo 还是仅用于客户端?
    【解决方案2】:
    request.userInfo = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"init", @"operation", nil];
    

    否则你会得到一个错误,比如:mutating method sent to immutable objectt

    【讨论】:

      【解决方案3】:

      如果您更喜欢括号而不是点表示法:

      [request setUserInfo:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"init", @"operation", nil]];
      

      【讨论】:

        猜你喜欢
        • 2012-01-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-15
        • 2023-03-17
        • 1970-01-01
        相关资源
        最近更新 更多