iPhone 용 objective-c에 대해 NSURLConnection
에 대해 질문하고 싶습니다.연결
데이터를 받기 위해 하나의 웹 서비스 (예 : YouTube 비디오)를 연결해야하는 앱이 하나 있습니다. 그런 다음 연결해야하는 모든 것들이 있습니다 (Hello_Soap 샘플 코드와 유사). didReceiveResponse
, didReceiveData
, didFailWithError
및 connectionDidFinishLoading
:
그러나 지금, 내 문제는 내가 Connection
라는 이름의 클래스를 (NSObject
에서 상속) 만들고 내가 방법을 구현 한 것입니다. 또한 방법
-(void)Connect:(NSString *) soapMessage{
NSLog(soapMessage);
NSURL *url = [NSURL URLWithString:@"http://....."];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
}
하지만 내 AppDelegate에에서 내가 한 Connection
개체를 만들 때 :
Connection * connect = [[Connection alloc] Init:num]; //It's only one param to test.
[connect Connect:method.soapMessage];
을 그리고이 방법을 호출이 완료 될 때, 그것은 didReceiveResponse
, didReceiveData
, didFailWithError
를 호출 계속되지 않습니다 또는 connectionDidFinishLoading
. 나는 이것을하려고 노력하고 있지만 나는 잠시 할 수 없다.
내가하고 싶은 건이 클래스를 "Connection"이라고 부를 때마다 데이터를 받고 싶습니다. (그 후에 파싱되어 UITableView
에 표시됩니다.)
감사합니다.
위임 방법도 게시하십시오. 또한 Objective-C 규칙은 메소드 이름이 소문자로 시작한다는 것입니다. – Chuck