ios - AFNetworking 2.0 对现有项目的更新
<p><p>我最近将我的项目更新为 AFNetworking 2.0,并且似乎缺少 AFHTTPClient 文件。 </p>
<p>我在以下网址阅读了以下内容:<a href="https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide" rel="noreferrer noopener nofollow">https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide</a> </p>
<p>看来我现在必须使用 AFHTTPRequestOperation 了?</p>
<p>如果是这样,我如何将以下代码修改为新的 AFHTTPRequestOperation?</p>
<pre><code>NSURL *url = ;
AFHTTPClient *client = [ initWithBaseURL:url];
];
;
success:^(AFHTTPRequestOperation *operation, id responseObject)
{
bool success = [ boolValue];
NSString *displayMessage = ;
if (success) {
NSUserDefaults *defaults = ;
;
;
// ;
;
;
} else {
;
}
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"error is: %@", error);
;
}];
</code></pre>
<p>更新:我做了以下事情:</p>
<pre><code>AFHTTPRequestOperationManager *manager = ;
NSDictionary *parameters = ;
[manager POST:WEB_SERVICE_BASE_URL parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
bool success = [ boolValue]? @"YES" : @"NO";
NSString *displayMessage = ;
if (success) {
;
;
} else {
;
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
;
}];
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>AFHTTPRequestOperationManager *manager = ;
NSDictionary *parameters = ;
[manager POST:WEB_SERVICE_BASE_URL parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
bool success = [ boolValue]? @"YES" : @"NO";
NSString *displayMessage = ;
if (success) {
;
;
} else {
;
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
;
}];
</code></pre></p>
<p style="font-size: 20px;">关于ios - AFNetworking 2.0 对现有项目的更新,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/21824265/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/21824265/
</a>
</p>
页:
[1]