Getting a function to recognize an integer

Moderator
Posts: 623
Joined: 2007.09
Post: #1
I have the following code;

Code:
#import "LGObject.h"

int tabNum;

@implementation LGObject

int tabNum

- (IBAction)addNewTab:(id)sender
{
    NSTabViewItem *tabItem = [[NSTabViewItem alloc] initWithIdentifier:@"Document2"];
    [tabItem setLabel:@"Document %d", tabNum];
    [newTab addTabViewItem:tabItem];
    
}
@end

And I can't figure out how to get the addNewTab function to recognize my integer. Is there a way to do this?
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #2
I think you want [tabItem setLabel:[NSString stringWithFormat:@"Document %d", tabNum]];

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #3
THANK YOU!!!!! Very much. When I am a famous programmer, I'll buy you a sandwich(If your teeth haven't fallen out by then.)
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #4
And now I have another problem. How do you pass the selected tab into the 'removeTabViewItem' function? I am trying to get it to where you press a certain button which gets the selected Tab and passes it into the removeTabViewItem function.
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #5
Have you not discovered the documentation yet? Help->Documentation and search for NSTabView.

NSTabview has a
- (void)removeTabViewItem:(NSTabViewItem *)tabViewItem method and an
- (NSTabViewItem *)selectedTabViewItem method.

You might need an IBOutlet to your tabview if you don't have one already, so you can talk to your tabview.

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #6
reubert Wrote:Have you not discovered the documentation yet? Help->Documentation and search for NSTabView.

NSTabview has a
- (void)removeTabViewItem:(NSTabViewItem *)tabViewItem method and an
- (NSTabViewItem *)selectedTabViewItem method.

You might need an IBOutlet to your tabview if you don't have one already, so you can talk to your tabview.

As a matter of fact, I have discovered the documentation and looked at it before posting here. If I type in the following under my "removeTab" action…
Code:
- (void)removeTabViewItem:(NSTabViewIten *)tabViewItem

I get a "removeTabViewItem undeclared" error. But, no matter, I found a solution.

Code:
- (IBAction)removeTab:(id)sender
{
[removeTab removeTabViewItem:[removeTab tabViewItemAtIndex:1]];
NSLog([NSString stringWithFormat:@"%d",[removeTab numberOfTabViewItems]]);
}
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
*Understanding* the documentation is as important as reading it Rasp
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #8
OneSadCookie Wrote:*Understanding* the documentation is as important as reading it Rasp

My thoughts exactly. I can't make head or tails of it.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Accelerate and working with Integer Arrays SIMD Bersaelor 6 5,958 Jul 6, 2010 07:56 AM
Last Post: Bersaelor
  Weird problem passing integer variables.. quarus 6 4,796 Mar 15, 2009 12:47 PM
Last Post: quarus
  reading integer input from user in C anthony 4 7,966 Nov 24, 2007 02:38 PM
Last Post: unknown