Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd items from NSSet to UITableView (convert NSSet to multiple arrays?)
    primarykey
    data
    text
    <p>I have a UITableView that adds information from a Core Data the following way:</p> <ol> <li>The "Category" for various names is added at the header</li> <li>The names that correspond to the Category should be loaded in cells beneath the Category</li> </ol> <p>Right now I have the header loading the right name and the right number of sections and rows being added. However - the results from Core Data are being returned as an NSSet, so I can't add each name to the cells based on the indexPath.row. </p> <p>Any suggestions? For reference: </p> <pre><code>cell.textLabel.text = [NSString stringWithFormat:@"%@",[[[dataToUse objectAtIndex:indexPath.section]valueForKey:@"heldBy"]valueForKey:@"name"]]; </code></pre> <p>Returns the appropriate set of names to each cell of the appropriate section, but it returns the ENTIRE set to each cell. I just want each name to be added based on which row it's a part of. I can solve this by converting the NSSet to an Array, but since there are multiple sets being created (because there are multiple categories) I don't see how I can do this. </p> <p>EDIT: I fixed my problem by doing the following, but I'm still interested to know what the best thing to do would have been.</p> <pre><code>NSSet *daset = [[dataToUse objectAtIndex:indexPath.section]valueForKey:@"heldBy"]; NSMutableArray *addToLabel = [[NSMutableArray alloc]init]; int i = 0; for(NSSet *contact in daset) { [addToLabel insertObject:[contact valueForKey:@"name"] atIndex:i]; NSLog(@"%@",addToLabel); i++; } cell.textLabel.text = [NSString stringWithFormat:@"%@",[addToLabel objectAtIndex:indexPath.row]]; </code></pre>
    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. 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