How do you create a NSTabViewItem containing NSImageView programmatically? I almost got it...
How do you create a NSTabViewItem containing NSImageView programmatically? I almost got it...
- Subject: How do you create a NSTabViewItem containing NSImageView programmatically? I almost got it...
- From: "Frederick C. Lee" <email@hidden>
- Date: Thu, 21 Oct 2004 12:59:21 -0700
Greetings:
Accessing a programmatically-made NSTabViewItem has yield the
following errors:
[Session started at 2004-10-21 12:21:57 -0700.]
2004-10-21 12:22:28.786 ricCountries[961] *** -[NSCFNumber length]:
selector not recognized
2004-10-21 12:22:28.787 ricCountries[961] *** -[NSCFNumber length]:
selector not recognized
Scenario:
1) I have two (2) existing NSTabViewItems containing NSImageViews
(maps of a country).
I wish to replace the two with three (3) new images: I've selected
three (3) images via NSOpenPanel to populate
the exiting two (2) that were created by IB. Thus I need to create
the third NSTabViewItem:
NSNumber *myNum = [[NSNumber alloc] initWithInt:numberOfTabs];
// Adding NSTabViewItem to menu:
if (lastReceivedTab > numberOfTabs) {
for (i = numberOfTabs; i < lastReceivedTab; i++) {
NSTabViewItem *tabViewItem = [[NSTabViewItem alloc]
initWithIdentifier:myNum];
[tabViewItem setView:mapImage1_View];
myNum = [NSNumber numberWithInt:([myNum intValue] + 1)];
[map_TabView addTabViewItem:tabViewItem];
}
}
2) So far, so good. I now have three (3) NSTabViewItems: {#0 & #1
created by IB and #2 created by the program}.
3) Now I need to populate all three (3) NSTabViewItems:
// NSRect: I'm using the same frame size as the IB-created NSImageView.
// {Is this nec? Apparently not. Using 'init' vs 'initWithFrame'
seems to work the same.}
NSRect defaultFrame = [mapImage1_View frame];
for (k = 0; k < [theMaps count]; k++) {
// Grab the image from the selected file (theMaps array):
NSImage *theImage = [[NSImage alloc]initWithContentsOfFile:[theMaps
objectAtIndex:k]];
switch (k) {
case 0:
...
break;
case 1:
...
break;
case 2:
mapImage3_View = [[NSImageView alloc]
initWithFrame:defaultFrame];
[mapImage3_View setImage:theImage];
NSTabViewItem *theItem = [map_TabView tabViewItemAtIndex:2];
[theItem setView:mapImage3_View];
[theItem setLabel:@"Three"];
[theItem release];
break;
case 3:
...
...
default:
break;
}
...
4) So far, so good. I see three (3) tabs (#0, #1, #2) with their
images. *However* is see some hidden problems:
When I click on tab #2 (program-supplied NSTabViewItem), I get the
following in the Run Log:
[Session started at 2004-10-21 12:21:57 -0700.]
2004-10-21 12:22:28.786 ricCountries[961] *** -[NSCFNumber length]:
selector not recognized
2004-10-21 12:22:28.787 ricCountries[961] *** -[NSCFNumber length]:
selector not recognized
Only this program-generated tab (#2) does this. The IB-generated tabs
are clean. When I re-populate the third (#2) tab, I get the following
error:
Executable “ricCountries” has exited due to signal 10 (SIGBUS).
I'm MISSING something when I try to create a new NSTabViewItem
containing a NSImageView programmatically. I do get a result, but not
completely clean. I'm missing a 'selector', apparently.
Any clues to what I'm missing???
Thanks!
Ric.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden