我有这个方法。
[self postRequestWithURL: (NSString *) postArgs:(NSDictionary *) headerArgs: (NSDictionary *) ];如何正确调用此方法?
url为:http://www.google.com/reader/api/0/edit-tag?
后参数是:"a=user/-/state/com.google/read&ac=edit-tags&s=feed/%@&i=%@&T=%@", entry.link, entry.identifier, tokenString
和header是:
NSString *authHeader = [NSString stringWithFormat:@"GoogleLogin %@", authString];
[thttpReq addValue:authHeader forHTTPHeaderField:@"Authorization"];
[thttpReq addValue:@"Content-Type" forHTTPHeaderField:@"application/x-www-form-urlencoded"];sompne可以帮助我在NSDictionary中插入postArgs和HeaderArgs吗?谢谢Paolo
发布于 2011-08-01 05:02:39
尝试如下所示:
NSDictionary *postArgs = [NSDictionary dictionaryWithObjectsAndKeys:
@"user/-/state/com.google/read", @"a",
@"edit-tags", @"ac",
[NSString stringWithFormat: @"feed/%@", entry.link], @"s",
[NSString stringWithFormat: @"%@", entry.identifier], @"i",
[NSString stringWithFormat: @"%@", tokenString], @"T",
nil];
NSDictionary *headerArgs = [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat: @"GoogleLogin %@", authString], @"Authorization",
@"application/x-www-form-urlencoded", @"Content-Type"
nil];
[self postRequestWithURL: @"http://www.google.com/reader/api/0/edit-tag"
postArgs: postArgs
headerArgs: headerArgs];请注意,dictionaryWithObjectsAndKeys:后面的列表包含对象和键的交替,用逗号分隔,后跟最后一个nil,如上面的示例所示。
顺便说一句,这里的字典是自动发布的,所以你不必显式地发布它们。
发布于 2011-08-01 05:02:35
您可以从阅读或文档开始。下面是你该怎么做:
NSString * feed = [NSString stringWithFormat: @"feed/%@&i=%@&T=%@", entry.link, entry.identifier, tokenString];
NSDictionary * parameters = [[NSDictionary alloc] initWithObjectsAndKeys: @"a", @"user/-/state/com.google/read", @"ac", @"edit-tags", @"s", feed, nil];https://stackoverflow.com/questions/6892183
复制相似问题