Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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