Link Between View Controllers in Subprojects - objective-c

I have a main project with a storyboard and then I have a subproject that doesn't have a storyboard. I want to have a button on my storyboard of the main project that when tapped takes you into the main view controller of the subproject. Could anyone provide some guidance with this?

You should be able to import any file created in the subproject in your main project using #import <SubProjectName/file.h>
If that doesn´t work means that you have not setted it up correclty. Make sure is marked as static library in settings. Here is a good explanation: http://www.blog.montgomerie.net/easy-xcode-static-library-subprojects-and-submodules

Related

Integrating a Nib based SQL3 Lite project into a tabbed bar

I have been looking around for a while and finally found a SQL Lite tutorial that perfectly suits my needs. I downloaded the source code from it.
This code however had plenty of depreciated code that I in turn fixed. Here is a link to my updated project. (HERE)
I have had quite a bit of experience integrating xib based projects into a tab bar project. But I'm stuck right at the beginning because in just about every file in this project there is a reference to SQLAppDelegate which is the app delegate of the SQL Project.
The problem I am having is that I have a storyboard project and already have an app delegate. If I included the code from SQLAppDelegate.h and SQLAppDelegate.m in my AppDelegate.h and AppDelegate.m of the storyboard project and include the code from RootViewController in the Tutorial project into my storyboard tabbar project view controller files and deleted RootViewController.xib and kept the rest of the files in my project, would that work?
E.g I would get rid of SQLAppDelegate.h and SQLAppDelegate.m and MainWindow.xib in the tutorial and integrate that code into my storyboard Appdelegate.h and AppDelegate.m.
Then I would take all the other files in the tutorial project and include then in my project with the correct frameworks. I would delete RootViewController.xib and keep RootViewController.h and .m , Then I would Integrate the setup of RootViewController.xib into my Tab I wanted it in my Tabbar storyboard. and make the correct references to it.
I would call that tab RootViewController in my storyboard.
I know I can include .xib files in my storyboard tabbar project and reference them from my storyboard. It works I've done it.
Would including the code inside SQLAppDelegate into my AppDelegate interfere with the code in the rest of my tabs?
Or can I just include SQLAppDelegate and the rest of the files into my project and reference them then delete MainWindow and _window code from my project and then make the relevant in my tab storyboard project connect to SQLAppDelegate?
This mite sound a bit confusing?
UPDATE
Okay... after trying to integrate it myself I came across a number of issues like
SQLAppDelegate *appDelegate = (SQLAppDelegate *)[[UIApplication sharedApplication] delegate];
Does not work in Arc and all in all I got about 10 errors and all I did was include the files within the tutorial project in my Storyboard tabbar project.
Who would have thought trying to use SQLite in a Storyboard Tabbar project was so difficult?
Is there any example of a Storyboard Tabbar Example out there that uses SQLite in one of the tabs?
The functionality of this project was so perfect. Sigh.
I found a Christmas Kepper App from raywenderlich.com/6603/basic-security-in-ios-5-tutorial-part-2 . A great tutorial, I downloaded the tutorial and aside from a few lines of depreciated code and 1 warning which I managed to fix, It works perfectly for what I want. :D

How do I add a new view to a single view application in Xcode

I started my app as a single view application. I have the view with various buttons and labels connected to code. I want to add a button that links to another view.
I found a tutorial that guided me to click on the project and add a UIView subclass. However there is no option for that ( I think because I started it as a single view application).
I'm pretty new to all this so if anyone can outline a simple way for me to do this that would be great! I am using Xcode version 4.3.2.
Thanks!
You need to add a new Objective C class. Please refer to this:
How to create new View Controllers in XCode 4.3
If you started the app as single view using xib file the to add a class just go to name of the project on the left pane and right click on it. Then choose add new file. The pop up will appear to allow you to choose what type of class you want to add. Depending to what the new view is you can choose uiview controller or uitableview controller and so on. Just make sure you check mark with xib for interface user. That should do it. Hope it helps.
Adrian

Xcode, can't find my class which I had created

I'm playing arround with Xcode (for iOS) and added a View Controller to my Storyboard. Now I've created a Class (File -> New File -> Objective-c Class) and made that a subclass of UIViewController. Now the .h and .m files are generated and listed on the left side in Xcode, but when I want to change the "custom class" of my added View Controller there is nowhere my class which I had generated. Am I doing something wrong?
Thanks in advance.
I've had the same problem. Quitting and opening Xcode will make the Class show up in the list.
edit: I've also recently found pasting the Class name will work in 5.02 Xcode.
I had the same problem. But I discovered that I was clicking inside the "window of storyboard" and was selecting a view, so with no viewController related to. My solution was: to click inside the owner, or the viewController from the left list, and then change the custom class.
There are multiple reasons and solutions....
#1
Select project icon in "Project Navigator".
Then go to your Target's Build Phases -> Compile Sources.
Finlly, click the + button, and add your *.m or *.swift file.
#2
In one case, the same file was added multiple times to project:
Remove all instance of the file.
Add file back to project (once).
Finally, select the file in "Project Navigator", and in the "File inspector" on the right, look at the "Target Membership" section. The app target (not the Test target) should be checked, similar to this:
#3
ANOTHER WAY IS
Save all my work;
Just quit Xcode & load it again;
Then I was able to insert the new outlet connection successfully.
#4
Close the project you are working on with.
Delete the【DerivedData】folder of you project.
Said folder may be:
Inside your project's folder,
Or, inside ~/Library/Developer/XCode/DerivedData/(your project)/
Or, somewhere else that was setup by you.
Restart you project.
#5
Simply Clean your Project,
Then Build Again,
Finally, check and/or run.
I'm not sure what you mean by " but when I want to change the "custom class" of my added View Controller there is nowhere my class which I had generated ". It seems like you are trying to make the UIViewController in your storyboard to be of the same type of your custom UIViewController subclass.
If that's the case, then select your UIViewController (make sure you're not selecting the UIView within that UIViewController)
With the UIViewController selected, open the right hand view and open the Custom Class tab, then start typing in the name of your UIViewController subclass.
If that isn't working, then you need to ensure that the in the .h file you say:
#interface MyCustomUIViewController : UIViewController
If it still isn't working, ensure that in storyboard you are selecting the UIViewController that you put down. If you are trying to fill in the Custom Class of a UIView with a UIViewController subclass, it shall not work!
If it all still doesn't work, try COMMAND+SHIFT+K, and COMMAND+B to Clean and Build!
Good luck.
Just a quick advice in case you are about to give up: Do check that the item you have in the storyboard is compatible with the custom class you created that you are trying to assign. For example, you cant choose a UIView based class if you have a UIImageView as a component in your storyboard. In that case, it simply wont appear in the dropdown list.
You don't have to completely quit Xcode. Just close all your Storyboard tabs completely and reopen a new tab by double clicking on it.
Solution for my situation - just close all other xCode windows (i got opened few projects at same time).
Also sometimes help cleaning of project.

How to associate new class files to be a view controller for a specific scene?

Alright, I will try and make this short and sweet. I recently created my first iOS app, and in my app I decided to go the storyboard route by selecting the checkbox when creating the project. On a side note, I recently just started developing in Xcode, keep that in mind. So I started by designing the GUI elements of my app, and before I knew it, I had 8 scenes in my storyboard file and one view controller. Needless to say the view controller has been populated with code from different scenes thus making it difficult to understand what does what in the view controller. In the spirit OO design principles, I thought it would be a good idea to create a separate view controller for each scene. So I created some class files for the project. When I try to associate the newly created class file with the scene my computer just sounds a beep / donk sound. I am trying to associate the newly created class file to a scene by selecting the scene in the storyboard / Interface Builder view, then displaying the Utilities pane on the right, then selecting the Identity Inspector at the top of the Utilities pane, then setting the Custom Class to my newly created class file, but when I type the name of the class and press enter I just hear a beep.
If any one has any insight or knows of a tutorial explaining this process please post. Part of the reason I am trying to do this is for code readability, better code management, and a better code structure for the application. I came across this stack thread explaining some of what I am talking about.
Also here's a picture of what my project looks like if that helps shed any light.
You need to consider the parent class of your controllers, UIViewController for example.
To do so, you must check the .h file and your xib/nib file.
I. In your .h file, you will be seing:
#interface ViewControllerWelcome : NSObject
Change 'NSObject' to 'UIViewController' - this will mean that ViewControllerWelcome has a parent class UIViewController.
II. In your nib/xib file:
1. Click on the controller that you are going to set from the storyboard.
2. Go to interface builder and click the "Identity Inspector" (third item from the left) from the Utilities panel.
3. You need to specifically set each controller's name (eg. ViewControllerWelcome)
Do these to all controllers from your storyboard.
Here's something you can read about ViewControllers and Storyboards.

How to replace the FirstViewController in a TabBar app with another view controller (Kal)?

I created an empty iPad TabBar application using XCode 4, without storyboards. I placed that app in a workspace. I then added the Kal source (obtained from the iPad Juice build) to the workspace as a separate project. The initial build was clean.
I then went to the Kal example (NativeKal) and added EventKitDataSource.h and .m, and NativeCalAppDelegate.h and .m. (The image below shows what files are in the example project)
This is the code from the NativeCalAppDelegate.h file:
I tried setting the first TabBar UIView controller to "KalViewController" as I would normally do when using Storyboards, but it isn't listed in the drop down list of classes.
The question is: how do I get the NativeCal example view controller to replace FirstViewController in the in my TabBar application?
Comments added as Answer.
My recommendation is to switch to storyboards it is a lot easier to do UITabBarControllers in them. You can do this by just creating a new storyboard and copy and paste everything into it and then control drag from the UITabBarController to the UIViewControllers that you want to be linked to the tab bar controller and it does the rest for you, everything else is the same after that. In storyboards you can set the first view controller to be loaded so if you need it to be KalController then you can set it when you set up the UITabBarController. You can also set this in the code. I found that storyboards were a great new feature to xcode, UITabBarCotrollers are a lot easier to do in them then in .nib files I could never get them to work.
Hope this has helped.