News for hackers. Stuff that matters.
Re:Your First iOS App – 100% Programmatically by danilocampos on Tuesday April 16, 2013 @01:30PM (#5559503)
So, a word of advice to new folks trying out iOS land:

Interface Builder is most emphatically your friend. The compile/debug cycle in iOS is sufficiently lengthy that laying out views programmatically gets very tedious very fast.

Besides realtime previewing of exactly how your view is going to look, IB also helps you understand how your layout is affected by rotations to landscape and differences in view height between device classes (3GS/4/4S vs 5).

Nibs make it easy to tweak and adjust – and even to throw away and start fresh.

Most importantly, though – every nib you use is code you do not have to maintain. If a UI object has some part of its API deprecated, your nibs don't care. They're automatically up-to-date.

Can you do every fancy thing you'd like with nibs? Certainly not. But you can do the basic braindead layouts of labels and buttons there, and you're much likelier to get what you want the first time. There's enough tedious code to wrangle in iOS as it is – don't create more for yourself by rejecting a mature, useful tool.

edit: For clarity, though, by all means, enjoy this solid tutorial so you understand how to get your hands dirty when necessary. Just don't fear the IB.

Re:Your First iOS App – 100% Programmatically by SeoxyS on Tuesday April 16, 2013 @02:07PM (#5559749)
I've been a Cocoa developer for close to a decade now, and I've gone back and forth on this many times, but by now I've settled 100% in the nibs-are-evil camps. There are several reasons for that:

- Nibs are a nightmare when working with version control and merge tools. Now, at least, they are XML instead of a proprietary binary format, but it's still a joke…

- Auto-layout in IB is provably the worst GUI I have ever used. It's completely impossible to make it do what you actually indent. I was one of the guys cheering and wooing in the audience when it was announced at WWDC 2011, but it's proven to be a huge flop.

- I have a similar experience with storyboards.

- Having classes that may be instantiated both from code or from NIB deserialization adds a layer of complexity and messiness to your app.

- Ultimately laying out your views in code doing some simple arithmetic is easier to reason about and more likely to do what you expect. (People have no problem doing it to lay out websites with CSS–it's not that complicated.)

At the end of the day, nibs make it a little easier to get started (like using Ruby on Rails, and the Active* set of libraries), but it does not belong in a serious project, as it would add a prohibitive amount of technical debt.

Re:Your First iOS App – 100% Programmatically by potatolicious on Tuesday April 16, 2013 @04:59PM (#5560862)
Since you seem to be catching some flak for your post, I'll elaborate a bit further.

AutoLayout is a constraint solver, and as such it's very easy to either over-specify or under-specify your constraints in a way where it no longer evaluates.

On top of this, AutoLayout also has a priority for each constraint such that if/when such a conflict occurs AutoLayout has some ordering as to which constraints get abandoned first.

When you run into cases where AutoLayout breaks, debugging is a chore. You have to go through your entire view hierarchy and query each view for its hasAmbiguousLayout flag, which will give you some pointers as to what views are breaking your whole layout.

Interface Builder makes this somewhat worse because it doesn't give you an easily understood 1:1 match between what you do in the UI vs. the code that gets generated out of the other end. The opacity makes it hard to triage AutoLayout failures.

We use AutoLayout in small parts of the app, and we've found that doing it in code has been preferable - for a system that is as easy to break as AutoLayout you really don't want to be poking buttons on the top of a black box in the hopes that whatever comes out the bottom is sane. If there was a more transparent mapping of Interface Builder -> NSLayoutConstraint this would be less of an issue.

Also, yes, XIB merges are one of the Prime Evils of Hell, second only to pbxproj merges.

Re:Your First iOS App – 100% Programmatically by cageface on Tuesday April 16, 2013 @08:54PM (#5561916)
It's hard for me to believe that Storyboards or AutoLayout were designed by someone that actually builds non-trivial apps for a living. They're the kind of technologies that look good in a one-hour conference demo but quickly fall apart in real world use. After nearly throwing my laptop across the room on my latest project I ripped AutoLayout out of my project entirely and went back to springs & struts + frame math.

What this means though is that a layout I can build in five minutes in Android with <GridLayout> takes hours in iOS and is utterly opaque to version control. This is a cost I have to pass on to my clients.

Re:Your First iOS App – 100% Programmatically by seivan on Tuesday April 16, 2013 @09:12PM (#5561993)
You need to learn AutoLayout putting the blame on it won't help you.
Re:Your First iOS App – 100% Programmatically by cageface on Tuesday April 16, 2013 @09:42PM (#5562125)
I understand it. The problem is that not only is it a fundamentally flawed concept but the tools are inadequate. Moving a control by as much as one pixel in IB can completely scramble your constraints, including deleting user constraints attached to properties.

The API is ridiculously verbose and the visual language is underpowered and cryptic. It's sad but going back to manual frame calculations actually saved me a lot of time.

I think a lot of iOS devs don't realize how crap it is because they haven't taken the time to learn how other platforms solve these problems in a much more logical & developer friendly way.

Re:Your First iOS App – 100% Programmatically by conradev on Wednesday April 17, 2013 @07:16AM (#5563771)
I agree that the IB implementation is crap.

The API, on the other hand, is very nice. Although constraints can be slightly verbose, they are ages better than having to manually re-layout views after every single change of the superview's bounds. Spring and struts are nice, but cannot replace all of the CGGeometry math which is equally as, if not more, verbose than adding constraints. Autolayout is add-and-forget. The only downside is that it is iOS6+ only.

Re:Your First iOS App – 100% Programmatically by cageface on Wednesday April 17, 2013 @09:50PM (#5568501)
Have you done any Android dev? I find the various layout containers there far, far more intuitive and explicit and semantically clear. Let's face it, 95% of UI is nested grid layouts. Plus, having instant visual feedback for layout tweaks is a big time saver.
Re:Your First iOS App – 100% Programmatically by micampe on Wednesday April 17, 2013 @03:50AM (#5563263)
Just let it be, cageface is on a mission.
Re:Your First iOS App – 100% Programmatically by rbritton on Tuesday April 16, 2013 @03:06PM (#5560130)
I tried using Auto-layout on an app when it was first released, but for anything beyond simple cases it's incredibly buggy and unpredictable. It's now the first thing I turn off in any nib.
Re:Your First iOS App – 100% Programmatically by goyalpulkit on Wednesday April 17, 2013 @05:07AM (#5563455)
I don't think that Auto-layout is buggy at all. It is, however, not very intuitive and requires using it the right way for it to work!
Re:Your First iOS App – 100% Programmatically by pablasso on Tuesday April 16, 2013 @03:13PM (#5560162)
Not any of those points is justified, "a nightmare", "the worst". You need to provide something to support all those affirmations.
Re:Your First iOS App – 100% Programmatically by ianstallings on Tuesday April 16, 2013 @03:36PM (#5560321)
It's called an opinion. This isn't a peer reviewed paper we're talking about. And his opinion is that merging Nibs is a nightmare. Does he need to document how he did it, when, where, and what the room temp was at the time to "justify" an opinion? Hardly.
Re:Your First iOS App – 100% Programmatically by coldtea on Tuesday April 16, 2013 @07:23PM (#5561585)
>It's called an opinion.

Which are like noses. Everybody has one.

>And his opinion is that merging Nibs is a nightmare. Does he need to document how he did it, when, where, and what the room temp was at the time to "justify" an opinion?

Does he needs to elaborate more in order to justify it?

Of course.

Re:Your First iOS App – 100% Programmatically by ianstallings on Wednesday April 17, 2013 @09:45AM (#5564424)
Well allow me to elaborate - have you ever merged two nib files? With today's variant you merge XML. With yesterday's variant you simply don't do it because it's not possible. So you're merging an obtuse XML file at best. In my mind that's painful versus merging clean .h and .m files where we know what's going on. So he's using colorful language to describe such situations - A "nightmare".
Re:Your First iOS App – 100% Programmatically by coherentpony on Tuesday April 16, 2013 @03:59PM (#5560481)
Try merging a .nib. You'll see first-hand how hard it is.
Re:Your First iOS App – 100% Programmatically by coldtea on Tuesday April 16, 2013 @07:26PM (#5561595)
Why merge it?

Merging isn't even funny with regular code.

How about having a process for who works on what or when?

Either than or let a single person be responsible for the UI.

Re:Your First iOS App – 100% Programmatically by cmeranda on Wednesday April 17, 2013 @01:54AM (#5562916)
We're a two person development team who sits in the same 5 foot radius and we've had to merge xibs semi-frequently. It's not overly viable to ask the person next to you what files they plan to work on in the hour, because that can be difficult to determine in advance. Additionally once I upgraded Xcode before my partner, and suddenly our xibs were out of sync. In terms of one person working on the UI, even if that's the case, the other person might change an outlet, or create a non-UI object in the xib. It's complicated to coordinate changes because the breadth of features (as they appear in the codebase) is unpredictable.
Re:Your First iOS App – 100% Programmatically by mh- on Wednesday April 17, 2013 @12:26AM (#5562683)
these things work well-enough in very small development teams.
Re:Your First iOS App – 100% Programmatically by pc86 on Tuesday April 16, 2013 @02:24PM (#5559849)
If you say "provably" you really do need to... prove it. What studies are you citing when you say IB auto-layout is "provably the worst GUI?"
Re:Your First iOS App – 100% Programmatically by spac on Tuesday April 16, 2013 @02:47PM (#5560016)
He might have meant "probably".
Re:Your First iOS App – 100% Programmatically by mratzloff on Tuesday April 16, 2013 @03:46PM (#5560383)
This is one of those quintessentially Hacker News exchanges that I have begun calling "Hacker News moments".
Re:Your First iOS App – 100% Programmatically by SeoxyS on Tuesday April 16, 2013 @08:14PM (#5561768)
I did :). I wrote the comment on the bus this morning on my iPhone, and the autocorrect failed me! I wish I could still edit it to add a little more substance, though – hard to be thorough on an iPhone screen.
Re:Your First iOS App – 100% Programmatically by bridgeyman on Tuesday April 16, 2013 @03:22PM (#5560228)
Do you use Auto Layout in code?
Re:Your First iOS App – 100% Programmatically by andrewljohnson on Tuesday April 16, 2013 @02:51PM (#5560038)
Perhaps the worst, most insidious, damning thing about IB is it keeps novice iOS developers novices. You end up with programmers who don't know what they don't know.

I can write UI code faster than any developer I've ever met who uses IB, and that's doubly true for class hierarchies I have subclassed for multiple apps, and triply true when it comes time to change those subclassed hierarchies. You note that IB is for simple UI layouts, but I would argue that for layouts that simple, the code is simple too.

Maybe it's a matter of how you think, but I can "see" the changes when I adjust the frames, colors, padding, resizing masks, and that's basically all IB will do for you.

IB will also happily confuse your localization effort, and introduce bugs when you ship apps with unreferenced XIBs.

Re:Your First iOS App – 100% Programmatically by jakebellacera on Tuesday April 16, 2013 @03:26PM (#5560252)
> Maybe it's a matter of how you think, but I can "see" the changes when I adjust the frames, colors, padding, resizing masks, and that's basically all IB will do for you.

I know what you mean. I'm not an iOS/Cocoa dev by any means, but when I write CSS I typically know what the outcome is going to be in my head because I've done it so many times.

Re:Your First iOS App – 100% Programmatically by jcampbell1 on Tuesday April 16, 2013 @04:53PM (#5560820)
I can see it in both code and interface builder. Doing it in code on iOS is like using CSS where the only selector is `#id` and there are no child selectors. Would you write CSS if you had to do this?

    #username-label { text-align:right }
    #first-name-label { text-align:right }
    ...
    #last-name-label { text-align:right }
    #address-label { text-align:right }
With CSS, you get nice things like:

    #user-form label { text-align: right }
iOS code looks more like the first example but it goes on for hundreds of lines. You can create something like classes by creating real classes, but then you end up with inheritance hell.

I find IB's WYSIWYG to be a lesser evil.

Re:Your First iOS App – 100% Programmatically by SeoxyS on Tuesday April 16, 2013 @08:05PM (#5561735)
Or you could use a loop :).

    for (UILabel *l in @[self.usernameLabel, self.firstNameLabel, …]) {
        l.textAlignment = UITextAlignmentRight;
        l.textColor = [UIColor redColor];
    }
Re:Your First iOS App – 100% Programmatically by bennyg on Tuesday April 16, 2013 @09:54PM (#5562169)
Or use a helper class (called Design.m/.h) with a call:

  +(void)styleLabelForCertainPage:(UILabel *)label {
       label.textAlignment = UITextAlignmentRight;
       label.textColor = [UIColor redColor];
  }
Then run those through your loops. If you're seriously considering writing a lot of lines for something trivial, then you're probably doing it wrong in Objective-C.
Re:Your First iOS App – 100% Programmatically by BHSPitMonkey on Tuesday April 16, 2013 @05:56PM (#5561198)
If your iOS code comes out looking that repetitive, sub-optimal code organization is probably the real culprit.
Re:Your First iOS App – 100% Programmatically by smj2118 on Tuesday April 16, 2013 @08:12PM (#5561761)
What about UIAppearance? You can specify appearance for a UILabel inside a specific container type.

http://nshipster.com/uiappearance/

Re:Your First iOS App – 100% Programmatically by sjdev on Tuesday April 16, 2013 @10:22PM (#5562268)
I love UIAppearance. I am not too well versed in CSS but UIAppearance adds a lot of what I have seen done with CSS. You can change the default appearance of most default elements really easily, and declare containers inside of that with a whole different set of defaults. It makes styling your app a really painless process. All you have to do to make all the UIToolbars in your app red, for example, is use this one line at the start of your program.

  [[UIToolbar appearance] setTintColor:[UIColor redColor]];
Re:Your First iOS App – 100% Programmatically by manmal on Tuesday April 16, 2013 @06:27PM (#5561372)
You could write generator/setter methods for aligning labels to the right, no need for inheritance here. But, smart categories and inheritance go a long way. The last time I tried IB, I really regretted it because I constantly had to click through all those element layers (object hierarchy inspector is not that good either). After about 2h I gave up and rewrote everything to code-only.
Re:Your First iOS App – 100% Programmatically by jallmann on Tuesday April 16, 2013 @02:05PM (#5559740)
Writing code in iOS is tedious, but IB is also dog slow and XCode becomes pretty unresponsive every time I switch to/from it. Not to mention the mess xibs make in source control. There is no reason for xibs to be human readable -- a binary format would limit diff hemorrhaging, and performance would certainly be helped by not having to process unholy amounts of XML. Either way, good luck merging xibs with multiple collaborators.
Re:Your First iOS App – 100% Programmatically by meeech on Tuesday April 16, 2013 @01:44PM (#5559592)
"There's enough tedious code to wrangle in iOS as it is – don't create more for yourself by rejecting a mature, useful tool."

That's probably true. But some of us learn better by doing the tedious bits (basically less magic) to see how everything works together, and then look for the path to remove the tedious bits (which would lead to using IB) once we have a better grasp of things.

So this tutorial is quite welcome.

Re:Your First iOS App – 100% Programmatically by danilocampos on Tuesday April 16, 2013 @01:49PM (#5559630)
Oh yeah – you should totally understand how the magic works. But there's an odd strain of fear against IB, so it bears mentioning.
Re:Your First iOS App – 100% Programmatically by koko775 on Wednesday April 17, 2013 @02:35AM (#5563038)
Hey, long-time iOS dev here. Interface Builder is emphatically a beginner's friend. For "major league" stuff it is wholeheartedly the enemy. Avoid Storyboards like the plague. It's merge nightmare city when in teams, and a big enough app will suffer under the complexity required. It's simply not worth the pain.

With DCIntrospect (https://github.com/domesticcatsoftware/DCIntrospect), positioning in code actually becomes easier than nibs. You can print out the view properties, tweak positioning, then once it looks right you can get the values you need to tweak your code.

Additionally, getting to know UIAppearance and adding categories to UIColor and UIFont that return your app's standard fonts let you create a styleable application with consistent typography and color palette.

Re:Your First iOS App – 100% Programmatically by abbott on Tuesday April 16, 2013 @02:59PM (#5560080)
I'd love one of these for Android.

I am also anti-nibs:

Examples — NIB caching; Managing UI in two places (class & IB); Nightmare managing versioning and diffs (same from @SeoxyS), especially in a team environment; "Having classes that may be instantiated both from code or from NIB deserialization adds a layer of complexity and messiness to your app" (Repost from @SeoxyS); Want a custom UI implementation? Forget about using NIBs

Without NIB's — yes you have to write a lot more code. Concerns of code bloat are overblown. Your viewcontrollers are likely already bloated without inline UI implementations.

It really comes down to personal preference especially on smaller projects/apps, but I'd argue if you have ever worked on a large scale app that you are responsible for maintaining and enhancing long term, your opinion of NIB dependencies will change. This is especially true as your team pushes the limits of the UI and app performance. If I was going to teach you how to write an app, I'd explain what NIBs are (known pros and cons) and let you decide for yourself. Just like explaining to (my) kids about religion.

Fun fact, not all WWDC examples use NIBs. Say what?! Blasphemy!

Re:Your First iOS App – 100% Programmatically by M4v3R on Tuesday April 16, 2013 @03:11PM (#5560153)
Also a fun fact: Stanford University in their CS 193p classes teaches how to utilize Storyboards. And Auto Layout. And everything else that Apple provides for the devs.
Re:Your First iOS App – 100% Programmatically by abbott on Tuesday April 16, 2013 @03:33PM (#5560290)
There is a huge difference between academia and real world products shipped by teams w/real world experience w/academic backgrounds.

Stanford academic guidelines endorsed and supported by Apple, Inc.

I wonder what approach Evan Doll uses at Flipboard...hmmm?

Re:Your First iOS App – 100% Programmatically by argonaut on Tuesday April 16, 2013 @10:58PM (#5562399)
While I have no idea why M4v3R made that comment, as it's utterly irrelevant what Stanford teaches in their iPhone app class, it's also evident that you don't even know what M4v3R is referencing. He's referring to a class Stanford teaches on making iPhone apps, which has nothing to do with any sort of academic guidelines. The professor chose to use Storyboards, and that's that.
Re:Your First iOS App – 100% Programmatically by abbott on Wednesday April 17, 2013 @02:19AM (#5562992)
Research would serve you well in the history of CS193P.
Re:Your First iOS App – 100% Programmatically by allr on Tuesday April 16, 2013 @03:49PM (#5560399)
+1 for this. Also, I18n with nib files is a pain, the CLI tool that xcode provide for translating nib files is a joke really... Also, if you have custom UI or a custom font, you're nib file will look like shit anyway...
Re:Your First iOS App – 100% Programmatically by objclxt on Tuesday April 16, 2013 @01:33PM (#5559521)
I agree with pretty much everything you say (especially now Apple will be pushing auto-layout for newcomers to the platform), but the one thing that's really bothered me with the "Your First iOS App" tutorial is that as some point it switched from NIBs over to a full Storyboard.

And Storyboards are certainly in principle a cool idea, but I've never seen a production app that has actually used them (please do correct me if you're reading this and use them in your own shipping app). As far as I know, Apple aren't dog-fooding them in their own apps either. I'm not sure of the benefits of introducing them as pretty much the first thing out of the gate. But I'm prepared to be wrong!

Re:Your First iOS App – 100% Programmatically by danilocampos on Tuesday April 16, 2013 @01:37PM (#5559543)
Yeah, Storyboards are still in their awkward phase. That's totally fair. And I don't yet trust them for running view navigation.

But you know what they're awesome for? Static table views.

If you want to build a grouped table view as login view, settings panel or the like, Storyboards are perfect.

I'm also a big fan of Storyboards for prototyping. You can get to a pretty good fidelity demo of your app's information architecture, and often you can re-use what you built when it's time to code the app for real.

(Though I often cut the Storyboard content out and paste it into a nib.)

Re:Your First iOS App – 100% Programmatically by brodney on Tuesday April 16, 2013 @01:55PM (#5559661)
Half the stuff on my storyboards aren't even connected. I treat it like a big nib file. It's excellent for having everything displayed in front of you, in one place, and you can add segues and other storyboard magic as needed.
Re:Your First iOS App – 100% Programmatically by nanijoe on Tuesday April 16, 2013 @02:01PM (#5559712)
How would you know if a production app was using Storyboards? I just submitted my first "Storyboard App" . It was a little uncomfortable for me seeing as I have gotten used to using NIBs, but I did it because I assumed Apple was moving away from NIBs.. I wonder how other people who use Storyboards do it..I pretty much had to sit at a desk with my MBP connected to external monitors anytime I wanted to do any work, just because the Storyboard required a lot of screen space.
Re:Your First iOS App – 100% Programmatically by objclxt on Tuesday April 16, 2013 @02:14PM (#5559783)
> How would you know if a production app was using Storyboards?

Because just like NIBs, Storyboards exist as part of an app's resource bundle, which is easily viewable. It is usually fairly straightforward to examine an IPA from the store and determine whether it's using NIBs and the like.

Re:Your First iOS App – 100% Programmatically by BHSPitMonkey on Tuesday April 16, 2013 @05:53PM (#5561181)
I think the most likely explanation is that the grandparent commenter was referring to their own experience with projects they've worked on.
Re:Your First iOS App – 100% Programmatically by Aqua_Geek on Tuesday April 16, 2013 @04:24PM (#5560652)
> And Storyboards are certainly in principle a cool idea, but I've never seen a production app that has actually used them

Fly Delta app uses them all over the place (first-hand experience) - they're fantastic for static cell table views. Admittedly, merging them can be a HUGE pain, though.

> As far as I know, Apple aren't dog-fooding them in their own apps either.

From what I've heard from an Apple engineer, Apple doesn't dog-food a lot of this stuff because the tools either don't exist yet by the time they need to ship or aren't stable. A lot (most?) of their apps end up being done programatically.

Re:Your First iOS App – 100% Programmatically by M4v3R on Tuesday April 16, 2013 @01:59PM (#5559690)
I'm writing a fairly complex iOS app, and I opted in for storyboards in it. It doesn't handle 100% of navigation, because I only was invited to work on the app at some point and I didn't feel to rewrite the whole thing, but I use it for a substantial part of UI. It gets a while to get used to, but then you have this very cool overview of this whole part of the app. Some static parts are done 100% in IB (like a menu with grouped-style UITableView, utilizing static cells), others only use placeholders which are filled in code. But it works, and it works pretty well.
Re:Your First iOS App – 100% Programmatically by Scorponok on Tuesday April 16, 2013 @01:56PM (#5559671)
Our app has ~15 view controllers laid out in a single storyboard, and we haven't had any issues with them. We only have one iOS developer, so I don't know if that makes a difference.

We don't really use segues, though, since they seem to add complexity if you want to pass data around between the view controllers.

Re:Your First iOS App – 100% Programmatically by tvon on Tuesday April 16, 2013 @02:44PM (#5559989)
In case you are not aware, there is UIViewController's `prepareForSegue:sender:` method (http://developer.apple.com/library/ios/#documentation/UIKit/...). In short you figure out which segue was being prepared (segue.identifier) and setup the destination view controller (segue.destinationViewController) as needed.
Re:Your First iOS App – 100% Programmatically by ant512 on Tuesday April 16, 2013 @02:47PM (#5560014)
I've got a production app I switched from nibs to storyboards. It's got a storyboard for the iPhone and a separate storyboard for the iPad. 58 views on each. I'm using segues for pretty much all navigation. It's working amazingly well for me.
Re:Your First iOS App – 100% Programmatically by andymoe on Tuesday April 16, 2013 @11:56PM (#5562603)
xibs get in the way really really quickly after you ramp up. I would rather have a solid UI library built out that I can use between apps than have to constantly reinvent the wheel and fight with xibs and the GUI editor. Maybe they are fine for one man projects but for larger apps and larger teams they are almost certainly a mistake especially if you use them all over the place.

I'm not saying they did not work for hipmunk or for you generally but every app I have taken over that uses them extensively has been a nightmare to get back on track. Maybe I just have not been burned by the roll your own approach yet but I sure have been burned by the use xibs for everything approach.

Re:Your First iOS App – 100% Programmatically by allsystemsgo on Tuesday April 16, 2013 @01:55PM (#5559665)
I jumped into iOS dev after storyboards so, I fear nibs... I've never used one. If I started with a storyboard, should I throw in nibs every now and then for certain tasks??
Re:Your First iOS App – 100% Programmatically by bennyg on Tuesday April 16, 2013 @05:25PM (#5561009)
I like to think of Nibs like classes. A lot of times I'll have a certain design I want reused throughout the app, and this works perfectly. For instance, in an app I'm working on now, I have a few different views that have scroll-views inside of them, with each object of the scroll-view being a view itself. In the last of the chain of views, I use a nib because there's a solid amount of data there, and visually designing it in IB is easier to iterate and make it look exactly like I want it to. I have a .m/.h attached to the view (just a subclassed UIView) with a custom init method, returning what is basically a custom object (that happens to be that .xib). It's super efficient to make changes and keep things looking good when the data or the feature-set needs to change.
Re:Your First iOS App – 100% Programmatically by BHSPitMonkey on Tuesday April 16, 2013 @05:59PM (#5561216)
Keep in mind, this scenario is just as good a candidate (maybe even better) for doing the layout in code rather than a nib.
Re:Your First iOS App – 100% Programmatically by bennyg on Tuesday April 16, 2013 @11:59PM (#5562612)
Here's why I say no it isn't:

The end product, what my nib is for, has 12 labels, three UIView border bars (1px thick), two UIViews just for a differing background color in a couple spots, and a UIImage. Now you're right, I could set all those in code, alloc all those labels and adjust their sizes and positions relative to the ones that came before and all of that jazz, and that's all fine and dandy. Until I realize that my design needs tweaking. So, instead of selecting all elements on the nib and pressing up twice for a two pixel shift, I'm sitting there editing 20 different things in a CGRect call... way more work.

So instead of doing it all in code, the way I went about was creating a subclass of UIView with a .xib file attached to it. The .xib has everything where I want it visually and it's connected to the header via properties of everything that needs to be dynamic. Then I made a custom init method that just takes in my object and returns a UIView object that is the totality of that nib loaded with the data I need it to be. All in all, instead of bloat, every time I need to return an instance of that custom subclass I effectively call something like this:

  UIView *newView = [CustomClass createCustomViewWithObject:(id)object];
And that's it - I'm free to put it wherever I want up the chain in my subsequent views.
Re:Your First iOS App – 100% Programmatically by danilocampos on Tuesday April 16, 2013 @02:06PM (#5559744)
Here's the haphazard way I'm using this stuff these days:

1. Non-view controller views. These typically go in nibs. Custom tableview cells, tableview headers used across multiple views, custom buttons, nibs are all fine for this. (And the UITableView API accepts nibs for setting up reusable cells.)

You can certainly do custom tableview cells in Storyboards, but it's weird because I don't know how you can re-use those cells across multiple tableviews.

2. View Controllers. These I'm often using Storyboards to build. Since they're great for static tableviews, Storyboards end up having a decent chunk of stuff built in them lately. It can be nice to look at two views side by side. I seem to be grouping related view controllers together in single storyboards.

Nibs have performance penalties if they're packed down with too many objects, as every single one has to be loaded into memory. My understanding with Storyboards is that they don't have this drawback, so that's helpful.