나는 다음 코드를 가지고 NSArray 대신 NSMutable 배열을 사용하려고합니다. 현재 메서드가 작동하지 않으므로 NSMutable 배열을로드하는 방법을 말해 줄 수 있습니까?NSMutableArray from NSArray
NSMutableArray *titles = [xpathParser search:@"//h3"];
을하지만 값을로드 않습니다
-(void) whatever{
NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"http://www.objectgraph.com/contact.html"]] dataUsingEncoding:NSUTF8StringEncoding];
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:htmlData];
NSArray *titles = [xpathParser search:@"//h3"]; // get the page title - this is xpath notation
TFHppleElement *title = [titles objectAtIndex:0];
NSString *myTitles = [title content];
NSArray *articles = [xpathParser search:@"//h4"]; // get the page article - this is xpath notation
TFHppleElement *article = [articles objectAtIndex:0];
NSString *myArtical = [article content];
내가 시도? [xpathparser ...]
이 NSArray
을 반환 가정
나는 당신을 투표 할 것이지만 "관례에 따라 참조 횟수가 1 인 객체를 반환해야한다"고 썼다. 이것은 기술적으로 잘못된 것이다. 실제로 자신의 링크를 읽는다면 객체 소유권 정책 섹션에서 "보유 횟수"라는 문구를 사용하지 않는다는 것을 알 수 있습니다. – JeremyP
@JeremyP 음, 좋은 지적입니다. 결정된. –
당신은 그 요점을 놓쳤습니다. Apple의 메모리 관리 가이드에 따르면 컨벤션은 당신이 그 대상을 소유하고 있다는 것입니다. 보유 개수가 1 인 구현 세부 사항입니다 (어쨌든 항상 사실 인 것은 아닙니다). – JeremyP