ToolBarButton AssetPickerType -- missing but NOT in sim mode


#1

Just sharing this with folks.

So when I was working in the AutoLayout section I used AL to take care of my UIImageView.

I had left my Toolbar IBOutlet reference in my DetailViewController but it was NOT BEING USED in my code.

When I ran this in the simulator it would work. When I ran it on the device the only icon being shown was the camera icon.

Xcode 5.1 seems to really MESS UP my xib files. Since my Toolbar OUTLET was not being used I deleted it in my BNRDetailViewController.m file. Then I got a ‘key’ unknown exception. I had to go into the xib file at a source view. Look at the elements and manually delete the toolbar IBOutlet reference in my code.

No clue what was going on as I always do lots of CTRL-SHIFT-K actions to CLEAN and then re-build.

What I found by adding one more NSLOG statement and adding another toolbar button is BOTH were NIL but ONLY when running on a device.

    // set the text for the toolbarButtonItem
    NSString *typeLabel = [self.item.assetType valueForKey:@"label"];
    if (!typeLabel) {
        typeLabel = @"None";
        NSLog(@"Type lable value is: %@", typeLabel);
    } else {
        NSLog(@"Who moved my cheese?");
    }
    
    self.assetTypeButton.title = [NSString stringWithFormat:@"Type: %@", typeLabel];
    
    NSLog(@"AssetButton %@", self.assetTypeButton);
    NSLog(@"Foobar button %@", self.fooBar);
    
    // set Dynamic Type Fonts for view
    [self updateFonts];

They WORKED in the simulator.
I guessed that somehow the Toolbar was getting ‘nuked’ since when it loaded I had no assigned reference to it. That in turn caused it to nuke it’s button collection. Odd that the camera button worked but it could be because of how the artwork/image got loaded? No clue but removing an UNUSED IB_OUTLET REFERENCE FIXED IT.

In short if you are NOT using an IBOutlet object that ‘contains’ a collection of other IBOutlet objects in our code. It will work in the simulator but NOT on the device.

This took a while to figure out on my own. Hope it helps someone.

Cheers