iOS AFNetworking 发布问题
<p><p>我目前正在尝试发布到一个 php Web 服务,该服务将查询一个 mysql 数据库并 [应该] 返回一个字符串值。我研究了 AFNetworking,但不明白如何使用从查询返回的值。例如:</p>
<pre><code> AFHTTPRequestOperationManager *manager = ;
[manager POST:@"http://samwize.com/api/poo/"
parameters:@{@"color": @"green"}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
</code></pre>
<p>我猜我操纵 responseObject 来得到我期望的字符串?任何帮助将不胜感激</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>AFHTTPRequestOperationManager *manager = ;
[manager POST:@"http://samwize.com/api/poo/"
parameters:@{@"color": @"green"}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSError *error = nil;
NSDictionary *JSON = ;
if (error) {
NSLog(@"Error serializing %@", error);
}
NSLog(@"JSON: %@", JSON);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
</code></pre>
<p>这会将您的 <code>JSON</code> 响应转换为 <code>NSDictionary</code></p></p>
<p style="font-size: 20px;">关于iOS AFNetworking 发布问题,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/29807696/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/29807696/
</a>
</p>
页:
[1]