0
- (void)viewDidLoad 
{
  //json parsing 
    for (NSDictionary *ResultDictionary in dataDictionary) {
        ResultTabObject *ResultcurrenObjet = [[ResultTabObject alloc]initWithDate:[ResultDictionary objectForKey:@"MATCH_DATE"] ATeamName:[ResultDictionary objectForKey:@"COMPETITION_CODE"];
        [self.ResultHolderArray addObject:ResultcurrenObjet];
    }
}  
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    static NSString *CellIdentifier = @"Cell";
    ResultTabCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    ResultTabObject *ResultcurrenObjet = [self.ResultHolderArray
                                 objectAtIndex:indexPath.row];
    cell.lblDate.text=ResultcurrenObjet.Date;
    return cell;
}
-(NSMutableArray *)ResultHolderArray{
    if(!_ResultHolderArray) _ResultHolderArray = [[NSMutableArray alloc]init];
    return _ResultHolderArray;
}

I receive the dictionary values by using above code now I have to pass the ResultDictionary to another viewController Thanks in Advance

Fabio Berger
  • 1,921
  • 2
  • 24
  • 29
fathima
  • 181
  • 12

1 Answers1

0

Well, there are several ways of doing this, but an easy solution could be adding a ResultDictionary property on your target view controller and setting it just before the view controller changes.

Of you are creating the target view controller manually then just do it there. If the view controllers are created and connected through Interface Builder you can set the property in the - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender method like this:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // You can use the segue identifier to make sure that you have the correct segue. If there is only one possible segue from your source view controller you can skip this step.
    if ([segue.identifier isEqualToString:@"your_segue_id"]) {
        DestinationViewController *vc = [segue destinationViewController];
        vc.resultTabObject = someResultTabObject; // get it from your array.
    }
}

PS: Looking at your code it occurred to me that you might mean passing the ResultDictionary to the cell rather then an actual view controller. If this is the case then just add a ResultDictionary property to your ResultTabCell class and set it inside - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath.

pajevic
  • 4,607
  • 4
  • 39
  • 73
  • Thanks Mr.Pajevic,,,Can u tell me how do i set the property in (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender method. – fathima Mar 02 '16 at 09:18
  • Thanks Mr.Pajevic...if i add the comment of vc.resultTabObject =ResultcurrenObjet but I have to pass the ResultDictionary – fathima Mar 02 '16 at 09:34
  • That doesn't matter, the principe is the same. Just make your property in the view controller to be a `NSDictionary` and name it accordingly. – pajevic Mar 02 '16 at 09:38
  • i try - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"PreviewVC"]) { PreviewVC *vc = [segue destinationViewController]; vc.ResultDictionary = ResultcurrenObjet; // get it from your array. } } got error ...when i type vc. it shows me the ResultDictionay and Result Hold Arry – fathima Mar 02 '16 at 09:44
  • can u pls show me how to do that ..because i never try before to pass the dictionary values for another view – fathima Mar 02 '16 at 09:55
  • First of all, I am unclear what you want to pass, the dictionary itself or some values from it. Please clarify. Second, this really is very basic programming we are talking about here - you really should know this if you work as a programmer. The fact that this is a view controller doesn't actually matter. You have a class (which happens to be a view controller) with a property - and you pass a value to the property by assigning to it something of the same type. If your property is a `NSDictionary` type you simply assign to it some `NSDictionary` you have. – pajevic Mar 02 '16 at 10:00
  • Thanks Mr.Pajevic....I Have to Pass the ResultDictionary ..In Result Dictionary Set of values is there so i have to pass those values To another View...and I never Try before I am new for the iOS Development – fathima Mar 02 '16 at 10:06
  • If you wan to pass the ResultDictionary which is of the type `NSDictionary` then make a `resultDictionary` property of type `NSDictionary` and assign ResultDictionary to this property like this `vc.resultDictionary = someResultDictionary;`. If you just want to pass some values from the dictionary you can make separate properties for each of those like an `NSString` property called `name`. Then you can do `vc.name = someResultDictionary[@"name"];`. – pajevic Mar 02 '16 at 10:13
  • But if I were to guess from your code I would think that you really want to pass the `ResultTabObject ` which was created from your ResultDictionary. – pajevic Mar 02 '16 at 10:15
  • Thanks Mr.Pajvic I got the Answer – fathima Mar 08 '16 at 05:35
  • Good. Could you then please accept the answer here so that the question gets marked as answered. – pajevic Mar 08 '16 at 08:53