Tiiba":1ivtzpox said:
So two IS enough? That's all I want to know.
You need to be sure and understand why.
The example you posted is (obviously) very contrived; but leads me to believe you are taking a trial and error approach to using Objective-C. Your other questions and postings related to Objective-C are similar. The underlying core of Objective-C is C. Objective-C is not a language designed similarly to C, it is C with an object framework embedded in it. As such Objective-C suffers from the many failings of C in comparison to the vast majority of C-like, or C-derived languages that have followed it. Java, and C# share many syntactical similarities to C but their core is so substantially different they do not suffer from the level of ambiguity that C presents to new developers. Syntax similarities are the only thing they really have in common. (And that has been diverging anyway).
C is a beautiful but unforgiving mistress. If you treat her right she will dance a beautiful endless ballet, treat her wrong and she will whisper hateful things into your ear and wait until the opportunity is right and will rip out your heart to crush it lifeless on the floor.
--
I had written a large response to your Table View thread, but I didn't post it, I had difficulties getting my point across, after reading this thread I feel the need to post in regards to the other thread as well. You need to accept that some things in Objective-C and Apples API frameworks are in the category of "This is how things are done and are not to be questioned". It sucks, but it's true.
Apple has determined that UIView allocations are expensive and creating a pool of UITableViewCell objects and recycling the pool is the way to use a tableView. You can fight it, but you cannot win. I will say that I despise that particular design choice as it gives me fits when I want a simple TableView with a few specialized cells in them. I found an example on the net where someone had created 1 subclass per Section for a TableView and I've found that it allows me to have code which is simple and straightforward enough that complex TableView settings screens don't give me hives.
The basic premise is simple enough: Your UITableView delegate has an array of Sections, each section is an instance of a class similar to the UITableView delegate. In your TableView delegate you call the section specific method in the section instance. This means if you have 4 sections in a UITableView that you have 4 classes to handle the various cells. If you use a new section for different cell types it can help simplify some of the special handling. A project I worked on recently has 1-3 cell types per section, with 4-5 sections per tableview. That would be up to 15 special cell types in a single UITableView delegate if it weren't broken down. Instead, with only a couple of cell types per section (and many with only a single cell type) it becomes much easier to handle both mentally, and code wise as the logic is straightforward and short.