NSViewController StoryBoard Opening Window Error - swift

I'm working on a program with several view-controllers, all of which I open at various instances as sheets, by controlling dragging from a button on one viewcontroller to another viewcontroller, and by selecting "Sheet". This has always worked, until now when recently tried to add another viewcontroller and connect it similarly. When I click the button to open it though, it crashes and throws the error: (NSButton): missing setter or instance variable. When I use the new button to open an old viewcontroller, it works, but when I use an old button to open a new viewcontroller, it doesn't. Anyone seen this before?

Turns out I wasn't specifying which viewController the data needed to be sent to so I made an if statement saying, "If this view controller, then" and "else" etc. which ended up working.

Related

Xcode 4 Error: "the view outlet was not set"

I'm starting to program using Xcode/iOS
I've been reading some books and tutorial...
For my first application, I tried to do a "Hello World"
I did the program following every single step in the right way, but when I run the application, the program crash...
I read some posts to find the solution, but even when I check or do the steps that the posts suggest, I still have the same error. I tried to do another project, but the result is always the same.
This the capture of my screen
Try to set your "View reference outlet to files owner" by dragging the link
from "Views" to "File's Owner" in your nib. I think that's why you are getting
the crash:
Change the Class of File Owner to your ViewController,
Then set the View Outlet Again..!!
If it doesn't work, delete the view and drag a new one from Library. Set File Owner and View outlet again.

How to load existing TableViewController on click of button iOS5

I created UIExamsTVC using storyboards.
Once cell is clicked, it takes me to UITestVC.
UITestVC has 10 questions, When I get to the last question #10, there I have a "Done" button. I would like to go back to the original UIExamsTVC once the 'Done' button Clicked.
In: UITestVC.m
#import UIExamsTVC.h
(on button click)
[self.navigationController pushViewController:UIExamsTVC animated:NO];
Compile error - Unexpected Interface name
How can I do this?
If you want to go back then you don't want to push anything new...that's just adds to the existing stack. If you got to the UITestVC through a push, you want a "pop" in order to go back. If you got there by presenting it modally, you want to "dismiss" it.
(What your actual error is telling you is that you can't use the name of a class when the method you're calling wants a reference to an object.)

iPhone [self performseguewithidentifier... ] is not showing the new view controller

I have been all over stackoverflow and all over Google and I cannot seem to figure this one out. Here's my scenario:
I have my app's "main screen" where the user first makes decisions about what they're going to do. The app works off of a CoreData database which is created by "importing" XML files. The user can choose to open an XML file attached to an email in my application, which automatically triggers my main screen to show up and run the import of the file.
I can get this far without any issues. In my storyboard, I have a segue called ParseSegue from my main screen to a view controller which will handle the parsing and give the user some status information.
When the main screen is called via the email app, the main screen automatically calls
[self performSegueWithIdentifier:#"ParseSegue" sender:self];
I then check for this segue name in prepareForSegue and it's a valid name. This is where I assign the file URL to the parser controller so that it can parse the correct file.
The problem is that the segue never actually happens. The prepareForSegue method gets called, the name "ParseSegue" can be checked against and is valid, but the segue itself simply does not happen. If I add a button to the main screen and tell it to perform the segue within the storyboard, it works fine. But calling it programmatically seems to do nothing.
It turns out that I was looking in the wrong place entirely. My problem was that in my appDelegate, where the app reacts to the incoming URL, I was inadvertently creating a new instance of my storyboard and my main view controller. This was different than the one which was already active and may or may not have been on the screen.
The controller I was creating was never actually shown. I only noticed this because the log:
NSLog(#"Source: %#", [segue.sourceViewController description]);
would show different memory addresses for my test (the button push) and the import test. This led me to believe that I was, in fact, working with two different instances of the storyboard and the app's main view controller. Thanks to Paul for the suggestion of logging the destination and the source controllers.

Weird XIB file issue

Experiencing a weird problem in a modified program written by me. In my first iteration, the view controller had an IBAction by the title userSpecifyingInput and had all my buttons wired up to this IBAction.
To make the design more sophisticated, I introduced userSpecifyingDigit and userSpecifyingLetter and accordingly had some buttons wiring up to the first IBAction (userSpecifyingDigit) and the next button wiring up to the second IBAction (userSpecifyingLetter).
Upon running my program, it gave me this error:
terminating app: NSInvalidArgumentException
Unrecognized selector sent to instance
And these selectors were alternating between userSpecifyingInput and userSpecifyingDigit which did not make sense as userSpecifyingInput was completely removed from my ViewControllers interface and implementations.
Now I am not sure why userSpecifyingInput still existed, but after dabbling with sent events, I noticed that the buttons were wired upto the new selectors as well as the old selector.
I had to manually remove the old selector from the touchupinside events for all the buttons.
Naturally this does not seem to be a very convenient way to go about proceedings and if the view controller selectors are modified then the touch events ought to be automatically removed.
Am I missing something here? This is a pretty open ended question with different answers
Eliminating an IBAction from your implementation will not remove any previous links to it in IB. I haven't heard of any XCode/IB preferences to shortcut this issue.
Sounds like the xib still thinks one of it's objects is hooked up to the UIViewController, but the function on the UIViewController is no longer there. To check and fix this...
Click on the xib file in the project navigator
Select the File's Owner
Click on the Connections Inspector
Verify that none of these connections are invalid
I would also look in the UIViewController to make sure no automagically created references exist here as well.

Building Login onto already existing app

I am building a login onto an completed app. The app have already used the appdelegate but in order to do the login, it needs to use the appdelegate. I am stuck at a point where I cannot "make a new reference outlet for your Navigation Controller to your App Delegate." since the appdelegate in not in my .xib.
How can I make the appdelegate appear on the .xib file so I can link it with the navigation controller?
Thanks.
We need to first understand the architecture of your app. But even without that, one solution that I could think of is this.
Create a viewController named ValidateViewController by right clicking on your project-> add new file -> UIViewControllerSubClass and check the xib option as well.
This will generate the following
ValidateViewController.h
ValidateViewController.m
ValidateViewController.xib
Write all your validations functions in this class. Write a function in this class that would return true on validation success and false on validation failure. Now let's use this class in your appdelegate.
Now in your appdelegate.h, import this ValidateViewController.h. All the validation functions that you defined in the ValidateViewController will now be exposed to be used just by creating and allocating an object of ValidateViewController in your appdelegate. I hope this is pretty straight forward for you. If not, we can look at it again.
Now in the applicationDidFinishLaunching method of your appdelegate, the first thing you do is you load this ValidateViewController as a modalView controller programmatically. Once loaded, call the functions and get the return values from your validate functions, if validation succeeds, dismiss this modalViewController otherwise, you pop up an alertView in the modalViewController saying, validation was unsuccessful and the user stays on the ValidationViewController. I think that should solve your problem. If you need more help please come back. If you find the answer satisfactory, please accept it.