iDevGames Forums
NSView loaded from bundle won't draw... - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: NSView loaded from bundle won't draw... (/thread-4535.html)



NSView loaded from bundle won't draw... - Joseph Duchesne - Feb 11, 2006 11:26 PM

Hi,
I am trying to load an NSScreenSaverView and display it in a PrefPane much like Apple's screensaver prefpane's screenssaver preview. I am loading the screensaver bundle and I know that the bundle is loading correctly because I have put an NSLog in a custom screensaver and it is being displayed in the console when I run this PrefPane.
Here's the function where I put my code and the code:
Code:
- (void) mainViewDidLoad
{
    SSBundle = [NSBundle bundleWithPath:@"/System/Library/Screen Savers/Flurry.saver"];

    Class SSBundleClass;

    NSLog(@"Bundle Info\n%@",[ [ SSBundle infoDictionary ] description ] );

    NSLog(@"Found and loaded principalClass");
    theStupidView = [[SSBundleClass alloc] initWithFrame:NSMakeRect(0,0,100,100) isPreview:YES];
    [theStupidView startAnimation];
}

The description displays properly, the initWithFrame: function is run on the bundle, but I can't get "theStupidView", (IBOutlet id theStupidViewWink to display. Yes, I'm frusterated Rasp. My .h file is linked to DesktopSaverPref in IB. The loaded class is a ScreenSaverView, a subclass of NSView. I really don't understand why it isn't drawing anything.

Anyone?
Thanks,
Joseph Duchesne


NSView loaded from bundle won't draw... - Cochrane - Feb 12, 2006 03:33 AM

You're trying to set an outlet to a different view and hope that the view the outlet was set to changes. This is not possible. Instead, you'll need to add the view to the view hierarchy, i.e. determine a view that it should be a subview of and then use addSubview, replaceSubview or a similar method to add the view there.