Tomas Svoboda
Tomas Svoboda

Reputation: 51

Set NSMutableArray as data source for NSTableView

I need to view data from NSMutableArray in NSTableView. There is the code:

- (IBAction)StartReconstruction:(id)sender 
{
    NSMutableArray *ArrayOfFinals = [[NSMutableArray alloc] initWithObjects:nil]; //Array of list with final images
    NSString *FinalPicture;
    NSString *PicNum;
    int FromLine = [TextFieldFrom intValue]; //read number of start line 
    int ToLine = [TextFieldTo intValue];     //read number of finish line
    int RecLine;

    for (RecLine = FromLine; RecLine < ToLine; RecLine++)  //reconstruct from line to line
    {
        //Start(RecLine);    //start reconstruction

        //Create path of final image
        FinalPicture = @"FIN/final";
        PicNum = [NSString stringWithFormat: @"%d", RecLine];
        FinalPicture = [FinalPicture stringByAppendingString:PicNum];
        FinalPicture = [FinalPicture stringByAppendingString:@".bmp"];
        [ArrayOfFinals addObject:FinalPicture]; // add path to array
    }

    NSBeep(); //make some noise

}

I need to set ArrayOfFinals as data source for my tableview in my app. I'm noob in cocoa, and I don't know where I need to make connections :(

I saw tutorial on youtube, but it didn't hepl me.

Upvotes: 0

Views: 1738

Answers (2)

Monolo
Monolo

Reputation: 18253

You can't really use an array directly as a data source, but you can use an NSArrayController in between and then use bindings to hook them up.

You won't need to write a single line of code for a basic set up.

There are plenty of step-by-step tutorials on the net for this.

Upvotes: 0

Nikita Rybak
Nikita Rybak

Reputation: 68006

SO is really not a place for step-by-step tutorials.
But on this subject there're many you can find online. Personally, I've found apple tutorial very informative (even if a bit verbose).

Upvotes: 1

Related Questions