Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

obey me
obey me
1,135 Points

Passing Data

no data was passed between my UIViewController called (DOG.h , DOG.M) and UITableView.. ANY idea guys why this is happening , Amit Bijlani

//DOG.h

   @property(nonatomic,strong) NSString *stringdata;
   @property (nonatomic,strong) IBOulet UILabel *dogname;

// DOG.m

 @synthesize  stringdata;

@synthesize dogname;

    -(void)viewDidLoad{

       dogname.text=stringdata;
       [super viewDidLoad];
       }

The tableview contain a list of dog types, to pass data I used the segue "showdogsegue"

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.identifier isEqualToString:@"showdogsegue"])
     {
       NSIndexPath *indexPath=[self.tableView indexPathForSelectedRow];
       DOG *destviewcontroller=segue.destinationViewController;

       PFObject *object=[self.typeDog objectAtIndex:indexPath.row ];
       //typeDog is an NSArray
       Dog*details=[[Details_User alloc]init];
       details.stringdata=[object objectForKey:@"username"];  
     }

}

2 Answers

Stone Preston
Stone Preston
42,016 Points

you need to set the property of the destination view controller, not allocate a new one. you also need to cast segue.destinationViewController to DOG

       NSIndexPath *indexPath=[self.tableView indexPathForSelectedRow];
       DOG *destviewcontroller= (DOG *) segue.destinationViewController;
       PFObject *object=[self.typeDog objectAtIndex:indexPath.row ];
       //typeDog is an NSArray
       destviewcontroller.stringdata=[object objectForKey:@"username"];
obey me
obey me
1,135 Points

I am also trying to pass data to an UICollectionview, do you have any ideas , should i use a query inside of the UICollection

obey me
obey me
1,135 Points

Stone Preston help !!! Please