Ability to "lock" elements via Interface Builder

Originator:rileytestut
Number:rdar://14514780 Date Originated:7/22/13
Status:Open Resolved:
Product:iOS SDK Product Version:n/a
Classification:Feature (New) Reproducible:n/a
 
Summary: 

Nibs are great. They're an excellent way to visualize your UI, and to make minor changes such as element positions or text fonts. However, it's also so easy to change an element via code, and then later forget about it. This leads to several frustrating build and run cycles trying to figure out what's happening, when clearly the Nib shows you've done everything correctly. If there was an optional attribute in Interface Builder to make it so classes cannot modify the object, *so* many of these issues could be resolved. This is especially important in shared code-bases. Someone may modify the Nib, while another person makes another adjustment in code which counteracts the Nib change.

Steps to Reproduce:

Create a single-view app. Open the storyboard, add a subview,  and give it whatever frame you want (you're the one who has to fix these bugs, so have some fun with it! Oh, and pretty background colors can't hurt.) Now, create some obscurely named method like

- (void)thisMethodDoesAbsolutelyNoInterfaceAdjustmentsIPromise

and naturally put in some layout adjustment code in here to change the view's frame. For bonus points, make the code practically impossible to find via search later such as:

CGRect unrelatedRect = CGRectMake(0, 240.0f/7.0f, CGRectGetMidX(self.subview.bounds), 100);
unrelatedRect.origin.x = 99; // Because why not?
[self.subview setBounds:unrelatedRect]; // This can't possible backfire
[self.subview setCenter:CGPointMake(17, 18)]; // Not even checking if this lines up on pixel boundaries or not!

Now go get some coffee or write a book or something. It's ok, I'll wait.

Finally, go back to your app several months later and try to figure out why the hell your subview isn't where it should be.

Expected Results:

Well, this is expected behavior, but it shouldn't be. Preferably a warning (or even an error) pops up saying "self.subview cannot be modified from code" or something.

Actual Results:

All kinds of hell results from this.

Regression:

Can't really think of something creative to put here, so I'll just let you pretend I did.

Notes:

Seriously, if you fixed this I would be forever in your debt. Plus I'll make a deal with you; if you give me a shout out at the next WWDC for coming up with this OMG AMAZING new feature, I promise to never use another private API. You can't get better than that from a developer :-)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!