서버에서 데이터를 가져 오는 다음 코드가 있습니다.NSHTTPURLResponse 해제 메시지가 할당 취소 된 인스턴스로 전송되었습니다.
-(void)loginForFaceBook
{
GTMOAuth2ViewControllerTouch *viewController;
viewController = [[GTMOAuth2ViewControllerTouch alloc]
initWithScope:@"https://www.googleapis.com/auth/plus.me"
clientID:@"27615...6qdi60qjmachs.apps.googleusercontent.com"
clientSecret:@"Fs8A...u2PH"
keychainItemName:@"OAuth2 Sample:
Google+"
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[[self navigationController] pushViewController:viewController
animated:YES];
}
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
if (error != nil) {
// Authentication failed (perhaps the user denied access, or closed the
// window before granting access)
NSLog(@"Authentication error: %@", error);
NSData *responseData = [[error userInfo] objectForKey:@"data"]; //
kGTMHTTPFetcherStatusDataKey
if ([responseData length] > 0) {
// show the body of the server's authentication failure response
// NSString *str = [[NSString alloc] initWithData:responseData
// encoding:NSUTF8StringEncoding];
// NSLog(@"%@", str);
}
// self.auth = nil;
} else {
// NSString *authCode = [NSString alloc]in;
NSMutableURLRequest * request;
request = [[NSMutableURLRequest alloc] initWithURL:[NSURL
URLWithString:@"http://api.kliqmobile.com/v1/tokens"]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60] ;
NSLog(@"%@",auth);
NSLog(@"ho gya success %@ :::: %@ :::: %@", auth.accessToken,
auth.refreshToken, auth.code);
NSMutableURLRequest * response;
NSError * error;
request.URL = [NSURL URLWithString:@"http://api.kliqmobile.com/v1/tokens"];
NSString *post = [NSString stringWithFormat:@"
{\"token\":\"%@\",\"secret\":\"%@\",\"service\":\"%@\",\"handle\":\"%@\"}",
auth.accessToken,auth.code,@"google",nil];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded"
forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
error = nil;
response = nil;
NSURLConnection *connection = [NSURLConnection connectionWithRequest:request
delegate:self];
[connection start];
}
나는 NSURLConnection
delegtes 방법을 구현하고 데이터는이
- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
{
NSMutableURLRequest * response;
NSError * error;
NSLog(@"Did Receive Data %@", [[NSString alloc]initWithData:data
encoding:NSUTF8StringEncoding]);
NSMutableURLRequest * requestContacts;
requestContacts = [[NSMutableURLRequest alloc] initWithURL:[NSURL
URLWithString:@"http://api.kliqmobile.com/v1/contacts"]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60] ;
[requestContacts setHTTPMethod:@"GET"];
[requestContacts setAllHTTPHeaderFields:headers];
error = nil;
response = nil;
NSData* data1 = [NSURLConnection sendSynchronousRequest:requestContacts
returningResponse:&response error:&error];
NSLog(@"WE GET THE REQUIRED TOKAN DATA %@ :: %@ :: %@", [[NSString alloc]
initWithData:data1 encoding: NSASCIIStringEncoding], error ,response);
}
처럼 잘 인쇄되어 있지만 내 애플 추락 얻을 후에는 다음과 같은 오류를주고있다;
[NSHTTPURLResponse release] : 해제 된 인스턴스 0xcb51070에 메시지가 전송되었습니다.
제발 어떻게하는지 알려주세요.