Switching Views using Xcode - xcode

Using Xcode do I need to create a new file for each view when it is connected to a button? Or does it work fine with just keeping the app under one h and m file?

Create a new file for each view. This will give you a new .h and .m file. Using MVC or single app view.

iOS app development follow the model-view-control design pattern, and as such, you should always create a new control (.m and .h file) for each new view.

Related

How generate ViewController.h file in Xcode?

I create a new ViewController and renamed class. But still, the .h file where I want to store outlets and action doesn't appear.
In your xib or storyboard file change the Class in File's Owner to mach the one you had renamed.
See image:
When you add a new view controller and you think files *your controller name*.h and *your controller name*.m should automatically create. In my case, I start building a project(not in Visual Studio) in XCode. And after that, my files appear.

Xcode drag and drop ViewController from one project to another

It happens that the IBOutlets in the new project are connecting to the storyboard of the original project? How to avoid? Or how to disconnect from the ViewController code?
Here you can see MainStoryboard_iphone is storyboard in original project, Main_iPhone_storyboard is storyboard in the new project.
Thanks.
I would suggest a simple hack if you don't have a lot of classes - create new files for every header file where you declare your IBOutlets and copy over the code - it might as well solve the problem.

Adding multiple Cib / Xib files in Cappuccino

Currently I'm working on a product that uses the Cappuccino Framework and the Objective-J language.
I created my project using this command after installing Cappuccino: capp gen -t NibApplication Myapp
The Problem I'm facing is that I want to keep my code and GUI clean.
By doing so I wanted to split the GUI up in separate Xib / Cib (compiled version Cappuccino can read) and separate controllers, like I do with iOS and Mac apps.
I couldn't find on the internet or on the docs how to do so.
Also, all the examples (including the NibApplication template) contains only 1 xib file.
In short what I'm after is to load a controller, based on a XIB file which holds the window. All the outlets are connected to the controller I loaded.
Is there anyone who knows how to do it?
Thanks in advance and have a nice day!
The typical way to do this is to use a CPWindowController or a CPViewController for each xib you want to load. Here's what it might look like:
var myViewController = [[CPViewController alloc] initWithCibName:"mynib" bundle:[CPBundle mainBundle]];
This would load Resources/mynib.cib from your main bundle. Normally you'd also subclass CPViewController so as to give yourself a convenient spot for your control code.
Fixed it myself! I used this tutorial: http://vimeo.com/8948460
But instead of using atlas I used XCode. Just follow the steps but with XCode and you'll be fine if you want the above to happen.

How to create an iPhone application starting from an empty project and then adding one resource at a time?

Instead of using the standard Xcode provided templates (view based, window based etc), is it possible to create a full fledged iPhone application by starting with an empty project ?
I mean can one first create an empty project first, and then one at a time, add the main.m file, then import the Frameworks, then add an xib, add UIApplication delegate class, make necessary connections etc...
Has anyone tried this? It would certainly help one understand the basic anatomy of an iPhone application.
Yes. At least in Xcode 4.2, there is the "Empty" project template with no files, targets or build configurations.

Why can't I see a Managed Object Class file template in Xcode?

I created a .xcdatamodel Managed Object Model file in Xcode. I selected that file in Groups & Files. Then I go to File > New... > and nowhere in the iPhone Templates / Cocoa Touch Class templates I see the "Managed Object Class" file template.
Does anyone know what can be wrong?
I usually need to also select the entities for which I want to generate the class files.
In Xcode 4, select the entity in the xcdatamodeld, then choose Editor Menu > Create NSManagedObject Subclass
If you are wanting to subclass NSManagedObject then I would highly recommend talking a look at mogenerator (github). It will autogenerate the subclasses for you AND keep them in sync as you update your model. It also has the concept of machine classes vs. human classes so that you can add convenience methods, etc. without your code being stepped on each time you update your model.
I've seen this problem before as well. Solution for me was to click on a non-data model file (in Groups & Files) and then click back on the versioned data model file (and entity within it) and then try File -> New File. Alternatively, restarting xcode, selecting the data model file (and entity within it) and then trying File -> New File also worked for me.
Click On the top left where it says "Simulator 3.1.2 | debug". Change it to "IPHONE Device 3.1.2 (BASE SDK)... voila. (SAMS iphone in 24hrs?? lots of typos and incomplete procedures!)
Managed Object Class file template can be seen under "Core Data" section of new file creation option of XCode 4.
The following screenshot depicts it.
Thanks,
prodeveloper.

Resources