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

Thomas Skjelstad
Thomas Skjelstad
11,541 Points

Passing parse.com information using Seague to change parseClassName

I set up my segue like this

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Check that a new transition has been requested to the DetailViewController and prepares for it
    if ([segue.identifier isEqualToString:@"parse"]){

        // Capture the object (e.g. exam) the user has selected from the list
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        PFObject *object = [self.objects objectAtIndex:indexPath.row];
        // Set destination view controller to DetailViewController to avoid the NavigationViewController in the middle (if you have it embedded into a navigation controller, if not ignore that part)
        FWProductTableViewController *detailViewController = (FWProductTableViewController *)segue.destinationViewController;
        detailViewController.exam = object;
        NSLog(@"%@", object);

    }
}

and in my detailTableViewController i have set it up like this.

- (void)viewDidLoad {
    [super viewDidLoad];
    self.myClass = [self.exam objectForKey:@"serieClass"];
    NSLog(@"%@", self.myClass);

}

- (PFQuery *)queryForTable
{
    PFQuery *query = [PFQuery queryWithClassName:self.myClass];


    return query;

}

- (id)initWithCoder:(NSCoder *)aCoder
{
    self = [super initWithCoder:aCoder];
    if (self) {
        // The className to query on
        NSLog(@"%@", self.exam);

        self.parseClassName = self.myClass;
        NSLog(@"%@ parseClassName",self.parseClassName);


        // The key of the PFObject to display in the label of the default cell style
        self.textKey = [self.exam objectForKey:@"navnFestival"];

        self.imageKey = @"produktBilde";

        self.textKey = @"serieFestival";

        // Whether the built-in pull-to-refresh is enabled
        self.pullToRefreshEnabled = YES;

        // Whether the built-in pagination is enabled
        self.paginationEnabled = NO;
    }
    return self;
}

In my mind it should be a valid way of doing it. But i get an console message saying

2015-03-22 17:09:09.814 Festival Fyrverkeri[1717:349918] 2015-12-31 17:00:00 +0000
2015-03-22 17:09:12.426 Festival Fyrverkeri[1717:349918] error: (null)
2015-03-22 17:09:12.647 Festival Fyrverkeri[1717:349918] error: (null)
2015-03-22 17:09:14.308 Festival Fyrverkeri[1717:349918] (null)
2015-03-22 17:09:14.309 Festival Fyrverkeri[1717:349918] (null) parseClassName
2015-03-22 17:09:14.310 Festival Fyrverkeri[1717:349918] <Serie: 0x14ed63b0, objectId: aXQehF5Rpr, localId: (null)> {
    serie = Blizzard;
    serieBeskrivelse = "Se hele Blizzard Serien";
    serieBilde = "<PFFile: 0x14f94520>";
    serieClass = Fyrverkeri;
}
2015-03-22 17:09:14.319 Festival Fyrverkeri[1717:349918] Fyrverkeri
2015-03-22 17:09:14.495 Festival Fyrverkeri[1717:349969] [Error]: bad characters in classname: (null) (Code: 103, Version: 1.6.4)

I can see the information is there, but it seems like parseClassName is loaded before the information is available for use. Anyone have an idea on how to fix this?

1 Answer

Thomas Skjelstad
Thomas Skjelstad
11,541 Points

Figured it out. I just had to do this

PFQuery *query = [PFQuery queryWithClassName:[self.exam objectForKey:@"serieClass"]];