Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kylebrowning

macrumors newbie
Original poster
Sep 22, 2008
2
0
I was curious if many people were building things between interface builder and xcode, or just using xcode alltogether and creating y our views and sub views programmatically?

I spent the latter half of the weekened trying to get some variables passed between views and the only real way I could do it was to create my own View classes, instantiate them, and then pass them to a navigation controller.

Doing things like navigationController.viewControllers = viewControllers, while viewControllers was of Type NSArray and contained my viewController with the proper objects was not working at all.

I had to create a navigation controller create the view controller, create the views pass them all into each other, then do a window addSubview.

Its fine if thats the method I continue to do, but I thought interface builder was going to be a lot more connection Oriented, and I would rather start learning to build everything out myself than go down a path where i get stuck because I rely on something that cant do what I need(IB);

Maybe I dont fully understand what an outlet is.

Ill keep reading my xcode book until these things make sense I suppose, but any help or push in the right direction would be appreciated.

Thanks.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
I use IB as much as possible to layout my UI. Others seem to have some difficulty doing that instead and lay things out in code. In fact there are some things that can't be done with IB and some things that are cumbersome as well as some things that are merely tricky. For some reason the majority of the Apple code examples don't use IB. I encourage you to do things using IB as much as possible.

Things that can't be done with IB involve view properties that, for whatever reason, aren't revealed in IB, so you must set them in code. Usually I do this in a viewController's viewDidLoad.

Things that are cumbersome include building UITableViewCells. I do this in code. Basically anything that is part of a UIViewController makes sense to do in IB. Something that is in a view that isn't attached directly to a viewcontroller is more complicated to do and I haven't taken the time to work it out.

One of the tricky things that took a while for me to figure out was having TableViews that didn't take up the whole screen and have a UITableViewController associated (rather than a UIViewController).

IB does still have some bugs and quirks that will trip up the unwary and frankly it still trips me up sometimes. I think that the greater number of these problems in the past is what has made some developers gunshy. For me laying out a UI in code is so 90's. Life's to short for that.

BTW, using the NavBar is one of the things that works very well using IB. Just layout your interface, build a UIViewController class for it, and pushViewController. It's three lines of code and works well.
 

kylebrowning

macrumors newbie
Original poster
Sep 22, 2008
2
0
So, how do you go about objects that exist in your AppDelegate, such as a plist file, and bringing that information/data to a navController/ViewController,

keeping in mind that when navController is instantiated it creates a new viewCOntroller.
Th only way I could get that to work is if i created the views and the views controller, then passing that information to the navController.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Not really sure what you're asking. Are you asking how does a view controller know about the views that it controls? If so the answer is via IBOutlets. Are you asking something else?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.