2011-10-18 15 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

ビデオは、通常は文句を言わないシミュレータで遊びます。ビデオを正しく再生するには、実際のデバイスで実行する必要があります。


また、デバッガでNSZombieEnabledMallocStackLogging、およびguard mallocを設定してみてください。そして、あなたのアプリケーションがクラッシュし、GDBコンソールで次のように入力します。

(gdb) info malloc-history 0x543216 

は、クラッシュの原因となったオブジェクトのアドレスで0x543216を交換し、あなたがはるかに便利なスタックトレースを取得し、それはあなたがピンポイントで役立つはずです問題の原因となっているコードの正確な行。

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