4

I do start off organising my .h files with the best intentions but somehow they get disgustingly messy.

Below is an example (which isn't that bad, but i've seen much worse!). I've tried grouping sections with #pragma mark but it seems to look even messier.

All the UILabels and UIButtons are required (as mentioned above) as they're showing data coming from a web service request so they're all required if we're using Interface Builder to design our GUI's. For example, the label might be a "weight" or "height" characteristic for a product.

Does anyone have any good advice on how to organise these in the most maintainable/readable way?

Cheers

alt text

Jamie Chapman
  • 4,229
  • 5
  • 29
  • 47
  • Do you really need to have that all in one class instead of splitting it up? – Georg Fritzsche Sep 13 '10 at 09:10
  • Actually, this is just some code I took out of our SVN. I didn't write it myself. But from what I know, it is displaying data from a web service in labels and the labels on the buttons change depending on the code... so the IBOutlets are required. – Jamie Chapman Sep 13 '10 at 09:29

1 Answers1

3

It strikes me as possible that you have too many properties, there. I've quite literally never seen any class with this many outlets; why are you addressing every single element in your layout? And why all from one controller?

It seems as if the best solution to your problem is to consider your class and split it up into multiple classes; each controlling one aspect of your interface. You also need to make sure that you really need to address all these elements. (The UILabels and UIButtons in particular seem like strange things to have outlets for.)

Williham Totland
  • 28,471
  • 6
  • 52
  • 68
  • Hi Williham, thanks for your response! All the UILabels and UIButtons are required (as mentioned above) as they're showing data coming from a web service request, so they're all required if we're using Interface Builder to design our GUI's. For example, the label might be a "weight" or "height" characteristic for a product. While the buttons push to another view to show further data about the product. – Jamie Chapman Sep 13 '10 at 09:31
  • 3
    Then you have no recourse but to split the class up into several, specialized classes. If this is as small as it goes, of course; it's as small as it goes, and there's not really anything to be done for it. – Williham Totland Sep 13 '10 at 09:43
  • 1
    Instead of using a UIScrollView containing labels with buttons that provide navigation, why not just use an instance of UITableView where the cells contain the text currently used to populate the labels, and then navigate when the user touches a row? – jlehr Sep 13 '10 at 14:47
  • @jlehr Thanks :-) We would normally do that under normal circumstances, but it was easier within the time constraints given the clients (awful) artwork. – Jamie Chapman Sep 14 '10 at 07:58