-1

I have a TableViewController with multiple cells(detail disclosure) each associated with unique data(eg. title/details). When I click one of the cells another ViewController gets loaded (via pushViewController) and should display the data depending on which cell was clicked.

Simple Eg:

Each Cell of TableViewController is associaed with separate urls. When I click one of the cell(detail disclosure), the next ViewController that contains a imageview should open the image corresponding to the url of the cell clicked.

This has to be done without Storyboards, Non-ARC

How do you do that?

This is what is i am writing in the DidSelectRowAtIndex

  NSMutableString *URL= [[SubFolderData valueForKey:@"URL"]objectAtIndex:indexPath.row];
    NSLog(@"URL %@", URL);
    File *FileUrl = [[File alloc]init];
    FileUrl.Url = URL;


    DocumentManagementAppDelegate *delegate=(DocumentManagementAppDelegate *)[[UIApplication sharedApplication] delegate];
    File *FileVC=[[File alloc]initWithNibName:@"File" bundle:nil];
    self.FileController=FileVC;
    [delegate.navigationController pushViewController:FileController animated:YES];
    [FileVC release];

SubFolderData is an array with data in it from which i am retrieving the URL only which is being done without any issue

Then i create a new instance of the second ViewController

In this "File" is the Second ViewController that has an NSMutableString "Url"

Vishal
  • 168
  • 1
  • 16

2 Answers2

1

overwrite the init method of the viewController with your own init method. for example

-(id) initWithTitle:(NSString *)title
{
     [super init];
      //your code
      //strore the title in your local variable.
     return self;
}

and while creating the viewController object

ViewController *vC = [[ViewController alloc] initWithTitle:@"VC Title"];
AMohan
  • 534
  • 1
  • 6
  • 15
0

in .h file of File

    @interface File : UIViewController
    {
            NSString *strUploadVideoURL;
    }

    @property(nonatomic,retain) NSString *strUploadVideoURL;
    @end

in .m file of File

    @synthesize strUploadVideoURL;

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
            self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
            if (self) {
                    self.strUploadVideoURL = [[NSString alloc] init];
            }
            return self;
    }

    -(void) dealloc {
            [strUploadVideoURL release];
            [super dealloc];
    }

in didselectrow method of mainview

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
            NSMutableString *URL= [[SubFolderData valueForKey:@"URL"]objectAtIndex:indexPath.row];
            [self.FileController setStrUploadVideoURL:URL];
            //code for push view.....
    }
DharaParekh
  • 1,730
  • 1
  • 10
  • 17