Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

varsis

macrumors regular
Original poster
Nov 30, 2005
209
1
Okay here is the setup. I currently Have:
Code:
	- (IBAction)addImage:(NSArray *)sender {
NSOpenPanel *open = [NSOpenPanel openPanel];
[open setCanChooseFiles:YES];
[open setCanChooseDirectories:YES];
[open setAllowsMultipleSelection:YES];
NSArray *fTypes = [NSArray arrayWithObjects:
@"jpg",
@"png",
@"jpeg",
@"gif",
@"tif",
@"bmp",
@"pcx",
@"raw",
@"pct",
@"rsr",
@"pxr",
@"sct",
@"tga",
@"JPG",
@"PNG",
@"JPEG",
@"GIF",
@"TIF",
@"BMP",
@"PCX",
@"RAW",
@"PCT",
@"RSR",
@"PXR",
@"SCT",
@"TGA",
nil];

	int result = [open runModalForTypes:fTypes];
	if (result == NSOKButton){
	NSArray *selectedFiles = [open filenames];
	int rows = [selectedFiles count];
	int i = 0;
while (i != rows) {
[thumb setDataCell: [selectedFiles objectAtIndex: i]  ];

	i++;

	}
What I need to do is add the NSTableView to Display the File Names and a Small Icon if possible. Also need to be able to edit and add other traits into the file. But I just can't figure it out. Anyone even help to export to the table.
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
If you want to display files in general the easiest is to use NSOpenPanel which is built in. Otherwise you need to stick the objects you wish to display in an array and look up NSTableDataSource in the Documentation to see how to get them to display.
 

varsis

macrumors regular
Original poster
Nov 30, 2005
209
1
Code:
- (int)numberOfRowsInTableView:(NSTableView *)tableView {

return [array count];

}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)row {
	    id theRecord, theValue; //define used variables
   if(row >= 0 && row < [array count]) {

   theRecord = [array objectAtIndex:row];// row of Dictionary
    theValue =  [theRecord objectForKey:[aTableColumn identifier]]; // Get Object With KEY of Column
	}

    return theValue;

}

Okay there is what I have for my NSTableView but it just won't work unless I specify the Array in the actual. I can't even add onto the array. It's an NSMutableArray.

Code:
- (IBAction)addImage:(id)sender {
NSOpenPanel *open = [NSOpenPanel openPanel];
[open setCanChooseFiles:YES];
[open setCanChooseDirectories:YES];
[open setAllowsMultipleSelection:YES];
NSArray *fTypes = [NSArray arrayWithObjects:
@"jpg",
@"png",
@"jpeg",
@"gif",
@"tif",
@"bmp",
@"pcx",
@"raw",
@"pct",
@"rsr",
@"pxr",
@"sct",
@"tga",
@"JPG",
@"PNG",
@"JPEG",
@"GIF",
@"TIF",
@"BMP",
@"PCX",
@"RAW",
@"PCT",
@"RSR",
@"PXR",
@"SCT",
@"TGA",
nil];

	int result = [open runModalForTypes:fTypes];
	if (result == NSOKButton){

	array = [NSMutableArray arrayWithObjects: [NSMutableDictionary dictionaryWithObjectsAndKeys:
			@"File tile 2",
			@"File",
			@"Type number 2",
			@"File Type",
			nil],
			nil];
			[tableView reloadData];
			
			printf ("%s", [[array objectAtIndex:0] objectForKey: @"File"]);

	
}
}

There is the other bit of code. I need to get that to add an array in. But nothing works? Anyone tell me what's wrong?

Interface looks like:
@interface imageTable : NSObject
{
IBOutlet id tableView;
NSMutableDictionary *fileDic;
NSMutableArray *array;
NSMutableArray *selectedFiles;




}
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Are you developing this on Leopard with GC enabled? If not, you need to retain 'array' after you assign it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.