안녕하세요. EXC_BAD_ACCESS (Code = 1, address = 0x10)
의 고전어를 사용하고 있는데 그 이유를 알 수없는 것 같습니다. 나는 다음과 같은 방법으로 오류를 얻을 : iOS - App with compelationHandler : nil
[Xsession logoutWithXId:[userInfo stringForKey:@"x_id"] compelationHandler:nil]
내가
EXC_BAD_ACCESS
오류가 발생하지만 난 그것을 호출 할 때처럼 :
[Xsession logoutWithXId:[userInfo stringForKey:@"x_id"] compelationHandler:^(BOOL hasCreated){}]
+ (void)logoutWithXId:(NSString *)xId compelationHandler:(void (^)(BOOL))hasSucceeded
{
NSError *error;
// create json object for a users session
NSDictionary *session = [NSDictionary dictionaryWithObjectsAndKeys:
xId, @"x_id",
nil];
NSData *jsonSession = [NSJSONSerialization dataWithJSONObject:session options:NSJSONWritingPrettyPrinted error:&error];
NSString *url = [NSString stringWithFormat:@"%@xsession/logout", potCatURL];
NSURL *URL = [NSURL URLWithString:url];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:30.0];
NSString *headerValue = [NSString stringWithFormat:@"Token token=%@", APIToken];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:headerValue forHTTPHeaderField:@"Authorization"];
[request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[jsonSession length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:jsonSession];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (error == nil)
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSInteger statusCode = httpResponse.statusCode;
if (statusCode == 200)
{
//********************* error happens here *******************************
hasSucceeded(true);
}
else
{
hasSucceeded(false);
}
}
else
{
hasSucceeded(false);
}
}];
}
하는 나는 방법과 같이 호출 할 때 빈 컴파일러와 함께 잘 실행됩니다. 왜 이런 일이 일어 났습니까, 누군가 설명해 주시겠습니까?
아무것도 전달 및 않는 무언가를 전달 사이에 큰 차이가있다 아무것도. –