Welcome to the iMore Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 2 of 2
  1. Thread AuthorThread Author   #1  
    smartsanja's Avatar
    iPhone Nanite

    1 Posts

    Default How to copy TableView cell data to a NSMutable Array ?

    I'm quite new to iphone development. I created To-Do List app using coredata. I want to add all the names from "oneHero" manageObject
    to a NSMutable array (that means name1 to 1st index position of MutableArray , name2 to 2nd index position of Array)

    this is my table view cellfor indexpath method
    - (UITableViewCell *)tableView:(UITableView *)theTableView  cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *HeroTableViewCell = @"HeroTableViewCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:HeroTableViewCell];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:HeroTableViewCell] autorelease];
    NSManagedObject *oneHero = [self.fetchedResultsController objectAtIndexPath:indexPath];
    NSInteger tab = [tabBar.items indexOfObject:tabBar.selectedItem];
    switch (tab) {
        case kByName:
            cell.textLabel.text = [oneHero valueForKey:@"name"];
            cell.detailTextLabel.text = [oneHero valueForKey:@"secretIdentity"];
        case kBySecretIdentity:
            cell.detailTextLabel.text = [oneHero valueForKey:@"name"];
            cell.textLabel.text = [oneHero valueForKey:@"secretIdentity"];
        //listData = [[[NSMutableArray alloc] init]autorelease];
           //[listData addObject: [oneHero valueForKey:@"secretIdentity"]];
     return cell;
    Actually what I want to do is, retrieve all the names(those are location names) from my "oneHero" object and then show
    those locations in a mapView.
    That's why I want to copy those names in to seperate NSMutable array
    or just as Strings
    Can you please give me a cording help . . .
    Last edited by smartsanja; 06-29-2011 at 06:32 AM.
  2. #2  
    jayfuerstenberg's Avatar
    iPhone Newbie

    14 Posts


    You should consider following MVC and use the table cells only for viewing the data. Store the actual data elsewhere and reference it from the table cell's view object.

Tags for this Thread

Posting Permissions