XML을 구문 분석하고 특성이 선언되고 보존되고 합성 된 문자열에 파싱 된 데이터를 저장했으며 값은 파싱하는 동안이 문자열로 전달되지만 파서를 마친 후에는 무효화됩니다. 파싱. 다른 IBAction 메서드에서 액세스 할 수 없습니다. EXE BAD ACCESS 오류가 발생합니다. 내 경험으로 볼 때 디버거가 잘못된 메모리에 액세스 할 때 발생한다고 생각합니다.파서 완료 후 문자열이 무효화되었습니다. iphone
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
//NSLog(@"found this element: %@", elementName);
currentElement = [elementName copy];
if ([elementName isEqualToString:@"resp"]) {
// clear out our story item caches...
}
else if ([currentElement isEqualToString:@"org"]) {
name = [attributeDict objectForKey:@"fileid"];
extention = [attributeDict objectForKey:@"extension"];
NSLog(@"image named %@ of type %@",name,extention);
}
else if ([currentElement isEqualToString:@"photo"]) {
photoid = [attributeDict objectForKey:@"photoid"];
NSLog (@"photo id = %@",photoid);
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
//NSLog(@"found characters: %@", string);
// save the characters for the current item...
if ([currentElement isEqualToString:@"userid"]) {
userid =[NSString stringWithString:string];
NSLog (@"user id = %@",userid);
}
else if ([currentElement isEqualToString:@"albumid"]) {
albumid =[NSString stringWithString:string];
NSLog (@"album id = %@",albumid);
}
}
이 부분은 잘 작동되지만
- (IBAction)download {
NSString *urlstr = [NSString stringWithFormat:@"http://staging-data.mysite.com/%@/albumphoto/%@/%@/%@.%@",userid,albumid,photoid,name,extention];
NSLog(urlstr);
NSURL *url= [NSURL URLWithString:urlstr];
NSData *imgdata = [[NSData alloc]initWithContentsOfURL:url];
UIImage *img = [UIImage imageWithData:imgdata];
newImage.image=img;
[imgdata release];
}
이것은 오류가 발생. pls 도움
문제를 진단하는 데 도움이되도록 출력, 로그 및 실제 오류 메시지와 그 행이 포함되어 있는지 확인하십시오. 또한 '사진'이라는 문자열을 저장하지 않고 URL에 좋은 값으로 알고있는 것을 제공하는 등 오류를 표시하는 가장 작은 것으로 줄이기 위해 노력하십시오. 그래도 오류가 발생합니까? –
'objc_message sent'는 – Nithin
으로 표시됩니다. 동작 메서드 내에서 하드 코드 된 문자열에 값을 지정하면 충돌이 발생하지 않습니다. 문제는 분명히 그 문자열이 0이되지 않게하는 것입니다. – Nithin