Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing values from custom NSView to NSCollectionViewItem
    primarykey
    data
    text
    <p>I have an NSTabView inside my custom NSView that is used as the prototype for the NSCollectionView. In the second tab I have NSButton button and NSImageView objects.</p> <p>NSButton is a "Browse" button that triggers the NSOpenPanel.</p> <p>I have connected the button's selector to IBAction in MyCustomView which performs the following:</p> <pre><code>// MyView.h @interface MyView : NSView { IBOutlet NSTabView *tabView; IBOutlet NSImageView *myImageView; IBOutlet NSButton *browseButton; } -(IBAction)openBrowseDialog:(id)sender; @end // MyView.m -(IBAction)openBrowseDialog:(id)sender { NSOpenPanel* openDlg = [NSOpenPanel openPanel]; [openDlg setCanChooseFiles:YES]; [openDlg setCanChooseDirectories:NO]; [openDlg setAllowsMultipleSelection:NO]; [openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@"png", @"jpg", @"jpeg", @"gif", nil]]; if ( [openDlg runModal] == NSOKButton ) { NSArray* files = [openDlg URLs]; NSURL* fileURL = [files objectAtIndex:0]; NSData *imageData = [NSData dataWithContentsOfURL:fileURL]; if( imageData != nil ) { NSImage *image = [[NSImage alloc] initWithData:imageData]; myImageView.image = image; [image release]; } } } </code></pre> <p>When I run this "myImageView" traces "null" in the Console even though I connected it as IBOutlet in Interface Builder. Could you explain why? How should I do this instead? I also need to pass the "fileURL" value to "representedObject" in my NSCollectionViewItem object but I don't know how to access that from here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload