Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It largely depends on what you are trying to do. An <code>NSArray</code> as a way to store all the text boxes you are using in you controller (instead of creating ivars for that purpose) is ok, but you could as well use a <code>UITableView</code>/<code>UITableViewController</code> for that.</p> <p>Using a table view would give allow you to grow the number of your text boxes without any effort. On the other hand, if you can guarantee that your text boxes will never be more than those you can display on a single screen real estate, I don't think using a table view would give you big advantages. But, as I said, this largely depends on what you are trying to do.</p> <p>If you decide to go for the array option, I would suggest using an <code>NSDictionary</code> instead, so that you can access each one of your views by name (or tag, if you associate a tag with each one).</p> <p>Also keep in mind that you could use the <code>getViewByTag:</code> method on your container view to get a reference to any view that it contains based on the view tag you assigned. So, you could do:</p> <pre><code>//-- creating text box: UITextField* textBox = ....; textBox.tag = 1; [self.view addSbview:textBox]; //-- accessing the text box: UITextField* textBox = [self.view getViewByTag:1]; </code></pre> <p>In this sense, a view already behaves as a container for you text boxes and gives you access to them.</p> <p>EDIT:</p> <blockquote> <p>Actually I'm trying to create a crossword grid</p> </blockquote> <p>ok, so, if it's 2-dimensional, I would say that a table view is ruled out (it is not impossible to do, but I think there are easier ways).</p> <p>as to your question, it all depends on how dynamic your crossword grid is: does it always have the same number of rows and columns? or can it be defined by the user? etc.</p> <p>In the first case, I would go for an <code>NSArray</code>, or I would simply use tagging as shown above (that would also make memory management automatic).</p> <p>Otherwise, you might inspect <code>UICollectionView</code>.</p> <p>If your question is: which data structure is more appropriate to handle a crossword puzzle? then, have a look at <a href="https://stackoverflow.com/questions/2288901/best-data-structure-for-crossword-puzzle-search">this post</a>. In any case, I would say: do not expect that you find a ready-made solution for that kind of problems...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload