2011-10-18 2 views
0

이것은 구현입니다. 헤더 파일에있는 모든 속성과 콘센트를 초기화했습니다. 나는 Xcode와 Obj-c 프로그래밍에 익숙하지 않고 작동하지 않는 iOS5 시뮬레이터에서이 비디오를 재생하려고합니다. 어떤 도움이나 조언을 많이 주시면 감사하겠습니다.XML 파서를 사용하여 비디오를 렌더링 할 수 없습니다.

#import "VideoMainViewController.h" 
#import "HotdogAppDelegate.h" 
#import "Video.h" 

@implementation VideoMainViewController 
@synthesize videoArray; 
@synthesize currentCateogry; 
@synthesize secondView; 
@synthesize thumbContainerView; 

NSXMLParser *xmlParser; 

-(VideoMainViewController *) initWithXML{ 
self.videoArray = [NSMutableArray arrayWithCapacity:0]; 
self.secondView = [[VideoSecondViewController alloc] init]; 
[self.view addSubview:thumbView]; 


NSString* path = [[NSBundle mainBundle] pathForResource:@"videos" ofType:@"xml"]; 
NSURL *url = [NSURL fileURLWithPath:path]; 
xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url]; 
[xmlParser setShouldProcessNamespaces:YES]; 
[xmlParser setDelegate:self]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onVideoBackClick) name:@"onVideoBack" object:self.secondView]; 

HotdogAppDelegate *application = (HotdogAppDelegate *)[[UIApplication sharedApplication] delegate]; 
[application addViewController:&self]; 
[super init]; 
return self; 
} 


-(void)viewDidLoad { 
[super viewDidLoad]; 
} 

-(void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    } 

-(void)viewDidUnload { 
[super viewDidUnload]; 
} 

-(IBAction) onMayoClick:(id)sender{ 
[self.secondView loadVideos:(NSMutableArray *)[self.videoArray objectAtIndex:0]]; 
} 
-(IBAction) onMustardClick:(id)sender{ 
[self.secondView loadVideos:(NSMutableArray *)[self.videoArray objectAtIndex:1]]; 
    } 
    -(IBAction) onKetchupClick:(id)sender{ 
[self.secondView loadVideos:(NSMutableArray *)[self.videoArray objectAtIndex:2]]; 
    } 

    -(void)stopVideo{ 
[secondView stopVideo]; 
    } 

    -(void) reset{ 
[self.view addSubview:thumbView]; 
thumbView.alpha = 1; 
if(self.secondView.view.superview){ 
[self.secondView.view removeFromSuperview]; 
} 
    } 


    -(void)parserDidEndDocument:(NSXMLParser *)parser{ 
[xmlParser release]; 
    } 

    -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
    namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
attributes:(NSDictionary *)attributeDict { 

if([elementName isEqualToString:@"Mayo"]|| 
    [elementName isEqualToString:@"Mustard"]|| 
    [elementName isEqualToString:@"Ketchup"]) { 

    self.currentCateogry = [NSMutableArray arrayWithCapacity:0]; 
    [self.videoArray addObject:self.currentCateogry]; 

}else if ([elementName isEqualToString:@"video"]) { 
    Video *video = [[Video alloc] init]; 
    video.thumb = [attributeDict objectForKey:@"thumb"]; 
    video.mp4 = [attributeDict objectForKey:@"mp4"]; 
    video.title = [attributeDict objectForKey:@"title"]; 

    [self.currentCateogry addObject:video]; 

} 
    } 

    -(void) dealloc{ 

for (NSObject *video in self.videoArray) { 
    [video dealloc]; 
} 

[self.videoArray removeAllObjects]; 
[self.videoArray dealloc]; 
[self.secondView dealloc]; 
[xmlParser dealloc]; 
    [super dealloc]; 
    } 


    @end 

`

답변

0

비디오는 일반적으로 늘 시뮬레이터에서 재생할 수 있습니다. 비디오가 제대로 재생되는지 보려면 실제 장치에서 실행해야 할 수도 있습니다.


또한, 디버거에서 NSZombieEnabled, MallocStackLoggingguard malloc을 설정하려고합니다.

(gdb) info malloc-history 0x543216 

가 충돌의 원인이 된 객체의 주소로 0x543216 교체, 당신은 훨씬 더 유용한 스택 추적을 얻을 것이다 그것을 당신이 정확하게 도움이 될 것입니다 그런 다음 응용 프로그램이 충돌 할 때, gdb를 콘솔에서이 입력 문제를 일으키는 코드의 정확한 줄

See this article for more detailed instructions.

+0

하나 ... 디버거가 많은 말을하지 않는 프로그램 내 메인 스레드에서 SIGABRT 메시지를 수신 받고 것 같다 .. 난 방법 ...하지만 메신저의이 라인에 오류가 궁금 코드 (VideoMainViewController *) initWithXML { self.videoArray = [NSMutableArray arrayWithCapacity : 0]; – irookie

+0

덕분에, 나는 스택 추적을했고 그것이 가리키는 라인은 아래에있다. 나는 그 오류가 무엇인지 알지 못한다. '[self.view addSubview : thumbView]; ' – irookie

+0

'self.videoArray = [NSMutableArray array];'로 변경해보십시오. 어쨌든 용량으로 초기화 할 필요가 없습니다. – chown

관련 문제