2013-02-11 3 views
0

다음은 내 파서를 유감스럽게 생각하는 항목입니다. 이 메서드는 내 viewController에 의해 호출됩니다.iOS 구문 분석 : 문자열이 null입니다.

013-02-11 15 : 26 : 18.564 DrillDownRSS [9251 여기

- (NSString*)img 
{ 
if (img!=nil) return img; 
    if (_description!=nil) 
    { 
// NSString* description = [NSString stringWithString:_description]; 
htmlParser = [[HtmlParser alloc] InitHtmlByString:_description]; 
    } 
return img; 
} 

내가이 같은 출력을 얻고 지금 내 파서의 초기화 방법 ...

- (HtmlParser *) InitHtmlByString:(NSString *)htmlString { 

NSString *description = currentHTMLElement.description; 
NSLog(@"%@", description); 
NSData *nsData = [[NSData alloc] initWithContentsOfFile:(NSString *)description]; 
elementArray = [[NSMutableArray alloc] init]; 

parser = [[NSXMLParser alloc] initWithData:nsData]; 
parser.delegate = self; 
[parser parse]; 

currentHTMLElement = [ArticleItem alloc]; 
        return self; 
} 

입니다 : C07 (NULL)

2013년 2월 11일 15 : 26 : 18.612 DrillDownRSS [9251 : C07 (NULL)

2013년 2월 11일 15시 26분 : 18.662 DrillDownRSS [9251 : C07 (NULL)

2013년 2월 11일 15 : 26 : 18.695 DrillDownRSS [9251 : C07 (NULL) 여기서


의 해결책이 아래의 코멘트의 덕분 사려 깊은 조언. 어떤 자기를 피하기 위해

// NSString *description = [NSString string]; 
NSData *nsData = [[NSData alloc] initWithContentsOfFile:(NSString *)string]; 
elementArray = [[NSMutableArray alloc] init]; 

parser = [[NSXMLParser alloc] initWithData:nsData]; 
parser.delegate = self; 
[parser parse]; 
NSLog(@"%@", string); 

currentHTMLElement = [ArticleItem alloc]; 
        return self; 
+1

이것은 아마도 관련이 없지만 왜 htmlString이 매개 변수로 전달되었지만 어디에서 사용되지 않았는지 궁금합니다. – yeesterbunny

+0

고맙습니다, 저를 도왔습니다. – Morkrom

답변

1

봅니다 변수/속성이 설명 이름 선언했다. 이상한 버그가 있습니다. 각 개체의 기본 설명을 무시하기 때문에