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

Fritzables

macrumors regular
Original poster
May 6, 2011
149
1
Brisbane AUSTRALIA
Hi All,

I am tearing my hair out here trying my hardest in populating a NSTableView.
I have taken a look on the net but it has confused me no end and I need help bad. All I want to do is populate only.

I have created a dictionary in the header:
Code:
NSMutableDictionary *unitOfMeassure;
In the 'm' file I have:
Code:
self.unitOfMeassure = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
		        @"centimeter/sec^2(cm/s^2)",kUnit,
			@"foot/sec^2 (ft/s^2)",kUnit,
			@"free fall (g)",kUnit,
			@"meter/sec^2 (m/s^2)", kUnit
			@"mile/hour second (mi/(h:s))", kUnit,
			@"millimeter/sec^2 (mm/s^2)", kUnit,
			nil];


I have declared the view like:
Code:
IBOutlet NSTableView *inputUnit;

So in the 'm' file how do I get the Dictionary into the TableView ??

Pete :mad:
 
Certainly have....

Must point out.... I am into my second week as a Mac user coming from Windows where I spent 15 years using Visual Studio.....

Need help adapting.
 
Sorry Robbie,

I guess it will have to be datasource from what I am reading ?!?!

Possibly. I always found it easier to get those working as I learnt to do this before binding existed :eek:

So you need to implement the datasource protocol in whatever object contains the dictionary and tell the table that this object will be acting as it's datasource.
 
I fully understand that..... but I am having trouble working out how to do that.
I have spent the last two days searching for examples on this and seen soo many variables.

I think the ol'e grey matter needs a rest up for a while - I'll hit it again tomorrow :)

When I first got into Coloa (last week) is thought it was so alien but I must admit I am slowly getting used to the new environment and some of the stuff ya can do in XCode....... makes VS look sad !!!

I'll get there Rob.

Pete
 
Well basically your object implements the methods defined by the protocol. You only have to implement the required ones, in this case two. You declare you are implementing the protocol in the .h file of your object:

Code:
@interface MyObject : MyBaseClass < UITableViewDataSource >
…

MyObject is whatever your object class is. MyBaseClass is whatever class you are inheriting from. The protocols between < and > are the ones you are going to implement (this is a comma separated list).

Then in your .m file you provide implementations for the methods defined in the protocols.

If you look at this page it shows the sort of method bodies you should be thinking about.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.