ios - AFHTTPRequestOperationManager 的 EXC_BAD_ACCESS
<p><p>首先调用“post 方法”,它使用 AFHTTPRequestOperationManager 工作正常。但是第二次我为同一个 AFHTTPRequestOperationManager 调用了 get 方法,得到了 EXC_BAD_ACCESS。请检查我的以下来源并帮助解决。 </p>
<p><strong>第一次调用“POST”方法——工作正常</strong> </p>
<pre><code>NSString *post =[ initWithFormat:@"grant_type=client_credentials"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES];
NSMutableURLRequest *request = [[NSMutableURLRequest
alloc] init];
];
;
;
;
forHTTPHeaderField:@"Authorization"];
;
;
;
;
AFHTTPRequestOperationManager *manager = ;
manager.responseSerializer = ;
manager.securityPolicy.allowInvalidCertificates = YES;
;
;
AFHTTPRequestOperation *operation2 = [ init];
operation2 = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
NSHTTPURLResponse *response = (NSHTTPURLResponse *)operation.response;
NSLog(@"Response: %@", operation.responseString);
NSLog(@"%ld",(long)response.statusCode);
NSData* data=;
NSString *response1 = [ initWithBytes: length: encoding: NSUTF8StringEncoding];
[ postNotificationName:@"check_auth_token_init" object:[ parseToken:response1]];
[ setNetworkActivityIndicatorVisible:NO];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", operation.responseString);
}];
;
</code></pre>
<p><strong>第二次调用“获取”方法-EXC_BAD_ACCESS</strong></p>
<pre><code>NSMutableURLRequest *request = [[NSMutableURLRequest
alloc] init];
];
;
;
;
;
//Here i tried to internalize "AFHTTPRequestOperationManager" but im getting EXC_BAD_ACCESS Please check attached screen shots
AFHTTPRequestOperationManager *manager = [ init];
manager.securityPolicy.allowInvalidCertificates = YES;
// Configure Request Operation Manager
];
// Send Request
AFHTTPRequestOperation *operation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", operation.responseString);
}];
;
</code></pre>
<p> <img src="/image/s6fOX.png" alt="enter image description here"/> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>警告“方法可能缺少 <code></code> 调用”表明您正在编译没有 ARC 的 AFNetworking,这可以解释为什么对象被过早地释放。</p>
<p>请按照 AFNetworking README 中提供的安装说明确保一切配置正确。</p></p>
<p style="font-size: 20px;">关于ios - AFHTTPRequestOperationManager 的 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/24901676/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/24901676/
</a>
</p>
页:
[1]