• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTableView question!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView question!


  • Subject: Re: NSTableView question!
  • From: Lorenzo <email@hidden>
  • Date: Tue, 17 Jun 2003 18:07:03 +0200

Hi,
simply add a NSArray in your "MyList.h" file like
==================================================
#import <Cocoa/Cocoa.h>
@interface MyList : NSObject
{
IBOutlet id theList;
NSArray *variableArray;
}
- (void)setTheArray;
@end
==================================================



Then use that array everywhere in your "MyList.m" file like
==================================================
#import "MyList.h"
@implementation MyList

- (int)numberOfRowsInTableView: (NSTableView *) tableView
{
return [variableArray count];
}

- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn*)tableColumn
row:(int)row
{
return [variableArray objectAtIndex:row];
}


// And, when you want to change the array, call this method
// passing the new array. Please note that you don't have to
// create nor retain nor release "variableArray". It's simply
// a pointer to your real array.
// "theList" is the IBOutlet id for the NSTableArray
// ---------------------------------------------------------
// setTheArray
// ---------------------------------------------------------
- (void)setTheArray:(NSArray *)theArray
{
variableArray = theArray;
[theList reloadData];
}
@end
==================================================


Best Regards
--
Lorenzo
email: email@hidden


> Dear list!
>
> I have a NSTableView. And in the same NSTableView I want to show the
> contents of 40 different NSMutable arrays. Not at the same time.
>
> Example: I want to show the contents of array 4 when I press a button, the
> contents of array 23 when I press another button and so on. But in the same
> NSTableView.
>
> Can I store everything in 1 array and just show the right rows when my
> buttons is pressed or must I have 40 different arrays? Or maybe there is a
> better way to solve this?
>
> Peter
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: NSTableView column headers
  • Next by Date: How to catch this crash?
  • Previous by thread: How to catch this crash?
  • Next by thread: Multi-texturing basics
  • Index(es):
    • Date
    • Thread