Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Segue crashing - debugger doesn't display any useful error

UPDATE:

Ok, I managed to log the exception:

[<TweetDetailViewController 0x685f9f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key toolbar.

I have a toolbar in the target controller view. Could that be causing the problem?


I have no idea what the heck is going on. I have not changed segues at all and they worked perfectly few minutes ago. I was changing some unrelated things in a detail view controller and now the app crashes during segue from the root to the view controller.

I am trying to debug this. Here is where the code crashes:

enter image description here

Step over:

enter image description here

Step over:

enter image description here

Step over:

enter image description here

Ok, here is the setter method which is being called in prepareForSegue:

- (void)setTweet:(Tweet *)newTweet
{
    if (_tweet != newTweet) {
        _tweet = newTweet;
    }
}

I call a configuration method when entering the detail controller:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [self configureView];
}

- (void)configureView
{
    // Update the user interface for the tweet detail page
    if (_tweet) {

        self.tweetUserName.text = _tweet.userName;
        self.tweetCreatedAt.text = _tweet.createdAt;
        self.tweetText.contentInset = UIEdgeInsetsMake(-4,-8,0,0);
        self.tweetText.text = _tweet.text;

        if (_tweet.retweeted == YES) {
            [self.retweetButton setTintColor:[UIColor grayColor]];
            [self.retweetButton setEnabled:NO];
        }

        if (!_tweet.userProfileImage) {
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                NSString *imageUrl = _tweet.userProfileImageUrl;
                NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]];

                dispatch_async(dispatch_get_main_queue(), ^{
                    self.tweetUserProfileImage.image = [UIImage imageWithData:data];
                });
            });
        }
        else {
            self.tweetUserProfileImage.image = _tweet.userProfileImage;
        }

    }
}
like image 953
Richard Knop Avatar asked Feb 21 '23 21:02

Richard Knop


1 Answers

Copied from comments, as an answer once the actual exception was revealed:

Most likely the TweetDetailViewController in your storyboard has some connection that links to an outlet called "toolbar" but the code for that class doesn't have a property with that name. That's the usual reason at least for that kind of error when a view controller is involved.

like image 101
Phillip Mills Avatar answered Mar 02 '23 21:03

Phillip Mills