Groping my way along with xcode and IB

Discussion in 'Mac Programming' started by mallrat68, May 5, 2010.

  1. mallrat68 macrumors newbie

    Joined:
    May 5, 2010
    #1
    Hi guys,

    So i'm trying to build a super simple little app (my first,) i'm working my way through a thick book on cocoa and trying to do follow tutorials I find online. Basically i'm trying to build a super simple little app that plays a video. I've been looking at the tuts on the apple site and this... I've built a simple video player using QTKit framework, and added some code from a tutorial into mydocument.m.

    I want the video player to load a single video that I have as an mp4, and have added it to the resources folder (through the project window)

    I'm basically trying to learn by smashing things together and this is where i'm at with the code:

    Code:
    #import "MyDocument.h"
    
    @implementation MyDocument
    
    - (id)init
    {
        self = [super init];
        if (self) {
        }
        return self;
    }
    
    - (NSString *)windowNibName
    {
        return @"MyDocument";
    }
    
    - (void)windowControllerDidLoadNib:(NSWindowController *) aController
    {
        [super windowControllerDidLoadNib:aController];
    }
    
    - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
    {
        if ( outError != NULL ) {
    		*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
    	}
    	return nil;
    }
    
    - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError
    {
    	NSString*   movieFile = [[NSBundle mainBundle] pathForResource:@"/testmovie" ofType:@"mp4"];
    	QTMovie*    newMovie = [QTMovie movieWithFile:movieFile error:nil];
    	if (newMovie) {
    		
            [self setMovie:newMovie];
    	
    	}
        return (newMovie != nil);
    }
    
    @synthesize movie;
    
    @end

    I'm not sure if i'm adding the pathforresource in correctly...

    any help would be greatly appreciated.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Describe the problem you're seeing.

    If you're not seeing a problem, then run your program and see what happens. If it has no problems, then move to the next thing. If it has a problem, then try debugging it.

    If you still can't get it working, then post your code (if modified from what's posted now) AND describe the problem you're seeing.
     
  3. mallrat68 thread starter macrumors newbie

    Joined:
    May 5, 2010
    #3
    sorry.

    when I build the code the app opens but the video window doesn't open and the video doesn't play. When I go to 'open' something from the menu in the app, it crashes.

    I haven't changed my code from the above, and i've tried debugging but I don't really understand the process (again, i'm reading up on this).

    My problem is that i'm not sure how to make the window appear from when the app is open (is this something I can define in IB?) and i'm not certain if i've connected the video file properly with the QTmovieview object in the code
     

Share This Page