그것은 아마도 간단한 문제 일 것입니다. 그러나 저는 잠시 동안 이것을보고 있었고 그것을 찾을 수 없습니다!ASIHTTPRequest가 충돌합니까?
나는 다음과 같은 SOAPRequest 클래스가 :
@interface SoapRequest : NSObject
@property (retain, nonatomic) NSURL *endPoint;
@property (retain, nonatomic) NSString *soapAction;
@property (retain, nonatomic) NSString *userName;
@property (retain, nonatomic) NSString *passWord;
@property (retain, nonatomic) NSString *postData;
@property (retain, nonatomic) NSObject *handler;
@property SEL action;
+ (SoapRequest*) create: (NSObject*) target endPoint: (NSString*) endPoint action: (SEL) action soapAction: (NSString*) soapAction postData: (NSString*) postData;
- (id)sendSynchronous;
- (void) send;
@end
구현 다음과 같이 :
@synthesize endPoint = _endPoint, soapAction = _soapAction, userName = _userName, passWord = _passWord, postData = _postData, action = _action, handler = _handler;
+ (SoapRequest*) create: (NSObject*) target endPoint: (NSString*) endPoint action: (SEL) action soapAction: (NSString*) soapAction postData: (NSString*) postData
{
SoapRequest *request = [[SoapRequest alloc] init];
request.endPoint = [NSURL URLWithString:endPoint];
request.soapAction = soapAction;
request.handler = target;
request.action = action;
request.postData = postData;
return [request autorelease];
}
그리고 내 보내기 기능 :
- (void) send
{
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:self.endPoint];
[request setDelegate:self];
[request addRequestHeader:@"Content-Length" value: [NSString stringWithFormat:@"%d",[self.postData length]]];
[request addRequestHeader:@"Content-Type" value:@"text/xml"];
if(self.soapAction)
{
[request addRequestHeader:@"soapAction" value:self.soapAction];
}
[request appendPostData:[self.postData dataUsingEncoding:NSUTF8StringEncoding]];
[request startAsynchronous];
}
나는에 기본 ASIHTTPRequest 방법이 있나요 오류를 듣거나 끝내면 다음과 같이 마무리됩니다.
- (void)requestFinished:(ASIHTTPRequest *)request
{
[self.handler performSelector:self.action];
}
이 클래스를 ASIHTTPRequest, [request setDelegate : self]에 대한 대리자로 만들려는 경우 충돌이 발생합니다. 나는 그것이 첫 번째 기능에서 Autoreleasing과 관련이 있다고 생각했다. 그러나 나는 그것을 고치는 방법을 모른다.
편집 :
이 내 SoapRequest 초기화하기 방법은 다음과 같습니다
- (SoapRequest*) DefinedEntities: (id) _target action: (SEL) _action
{
// some data inits
SoapRequest *request = [SoapRequest create: _target endPoint:endPoint action:_action soapAction:soapAction postData:xmlString];
[request send];
return request;
}
을 그리고 이것은 내가 다음과 같은 초기화하기 : 인스턴스를 만드는 곳
Metadata *service = [[Metadata alloc] init];
[service DefinedEntities:self action:@selector(MetadataFinished:)];
:
나는에-사이의 클래스해야했다. – JosephH'[autorelease 요청]을'return request '로 바꾸면 어떻게됩니까? – dragonfly
그러면 작동합니다. 이미 알고 있습니다. – Wesley