Interface Builder shows old Received Actions - iphone

When I open my xib file in Interface Builder and click on File's Owner in the Document window, the Connections Inspector is showing far more actions below Received Actions than I have defined in the class as specified by the File's Owner Class Identity.
I have only two IBAction items defined in the class, and both of these actions are shown and hooked up to the appropriate buttons. I am not sure where these other ones are defined, as when I search the project for the text of the action shown, it is not found anywhere in my project. (I believe that the actions shown are from a previous software application that I did on this same computer.)
I cannot find any way to get rid of these, and while the application still works as it should, I would like to try to find a way to get these actions out of there.
I am using the most recently released iOS SDK 4.1.

You may need to just edit the xib file by hand and remove the invalid actions.

Related

Function across multiple view controllers

I am trying to make a function so that I request a 'manager override' where it presents a screen for a manager to enter their password and press an approve button. How should I do this? Will it have to be in multiple functions? Is there a way that I can call one function and it present the information back? Would a completion work for what I need? I have no ideas where to start for this.
My set up is as follows:
A view controller asks for manager approval, then a screen slides up with text boxes and an approve button. I want the approve button to trigger authenticating and dismissing the screen
Assuming you don't want a Framework target (that sounds like overkill for what you want) simply mark the function as "public" and move it outside of any class. I just tried in a sample project and it works.
It looks important - remember to keep it in a file already in the project. (My sample project didn't work with menu option File|Add|New|File.)
Now, if you really want portability, check out how to create a Framework project.

Swift ViewController does not respond to -getFile, Could not connect action, target class

My code works all fine but there is always two console message every time I run it.
app works fine but the messages just bugs me so much. Could anyone tell me what is wrong with my code and what does these console message means,thanks
2016-06-13 14:31:15.014
LazyHackintoshGenerator[1625:37250] Could not connect action, target class
LazyHackintoshGenerator.ViewController does not respond to -getFile:
Select your ViewController.
Right-click on its “View Controller” icon (the blue circle with a white square inside).
Look for warning icons (yellow triangles).
Hover over them. An explanation of the problem will appear.
As Feldur said, the problem is probably a leftover link from your storyboard to a method that does not exist anymore (maybe you renamed it or deleted it manually). Remove the link by clicking on the cross, and, if needed, re-link to the appropriate method in your code.
Here is an example of what it will look like in Interface Builder.
Likely a control's action in your storyboard is linked to a method getfile that no longer exists

Unknown class in Interface Builder file

Why am I still getting this error when I run my iPhone app? The file is a ViewController that I have been working to delete and replace, but it just won't die. As far as I know, I don't have any reference (string or otherwise) to this file in my project.
I have deleted the related file (I'm trying to get rid of it.)
I have cleaned the project and rebuilt.
I have "Reset Content and Settings" in my simulator.
I have done a grep (grep -i -r "TheClassName" *) and nothing matches except my UserInterfaceState.xcuserstate file.
I have searched the code using XCode's Find/Replace tab.
I have double checked my Build Phases and am pretty sure it isn't in there (its a large project).
Any other ideas? I've spent way too many hours trying to figure this simple thing out; I must be missing something.
Thanks!
Check your nibs or storyboard, and make sure none of your views are set to the class!
I finally fixed the problem after trying it on multiple machines over the course of almost 2 days! I will not be thwarted!
I tracked the problem down to a call to setViewControllers on a UINavigationController which is called on initialization of the application. I was always being passed 3 objects (there are 3 panes in the navigation controller). Even though I had deleted the third object, as previously explained, three objects would always be passed in. The class type of the first two was correct, but the third would just be a UIViewController. Curiously, this view controller had a nibName which corresponded to the object file and Xib file that I had previously deleted. Of course, when view was called on this borked UIViewController, it would crash since the corresponding nib had obviously been deleted. Remember, the textual name of this object or Xib could not be found in my directory with grep, so I have absolutely no idea how in the world it came into existence when I ran my app.
So, I figured the app may not have been cleaned properly. I double and triple checked this. I even validated that my Workspace settings were correct (File->Project Settings->Advanced). The app was indeed being recompiled fresh every time.
Secondly, I started thinking that perhaps the object was being set by some other means. Working backwards, I added some breakpoints and found out that initWithCoder was being called on the parent UINavigationController--this was eventually working down to call the setViewControllers on the object and assigning the three view controllers (one of which was the offending one). I could easily see from the call stack that the Nib file that was being loaded was deserializing something offensive.
So, I started digging into my Xib file. Of course, the object name wasn't in the file (as expected since the grep didn't find anything). I deleted and recreated the portion of the Xib that included my root UINavigationController. This ended up changing the Object ID and ref within the Xib file.
Secondly, I created a new Xib and UIViewController with the same names as the one which I had previously deleted, hoping that Xcode might be happy if I created and then re-deleted them. I then compiled, re-deleted them, updated by Xib file yet again, reverified with grep that yes, indeed, nothing existed with that name.
And it worked. After spending multiple days on this issues, I'm fairly sure that there is a bug here in the interface builder, but do I want to revisit this problem to file a bug report? Absolutely not...
In my case, I solved an issue by name of Custom class name of View instead of Custom class of ViewController. By mistake i added like this for view as shown below.
It Should be for ViewController like this.
This is in my case, for you may be it's related with another component.
This happens when the view class is in a framework. Select the framework's module. Example with a CocoaPod: HSegmentControl.
Make sure when you add or rename or move files around especially in folders, that when you add them you:
A. Create Groups, not references they don't usually read in.
B. Check the boxes for the apporpriate "Product(s) or Target(s)" you want to add the source to.
Another thing to try :
I had to toggle "Inherit from Target" under the "Module" control of "Custom Class."

Recreating a Duplicate iPhone Project with Interface Builder Errors

Due to some extraneous errors in a previous XCode project that wouldn't allow my iPhone app to run on the iPhone, I had to take all the code and files from what we'll call Project1 and build a new project called Project2.
I then filled Project2 with all the same files, not changing any code.
Next I had to recreate the Interface Builder files. As far as I can tell, this was done with the exact same classes declared in all the IB objects.
However, when I build Project2, it only shows a visible black screen and doesn't display the app.
The one difference I have found between the two projects is that in Project2's Interface Builder, the ToolbarController outlet is not even available for the view, and it is in Project1. I am assuming the lack of connecting the File View to ToolbarController is the problem.
Why is ToolbarController (as shown below) not available and how do I fix this difference?
Below are two screenshots. The first is Project1 and the second is Project2. :
alt text http://img32.imageshack.us/img32/8296/picture1xne.png
alt text http://img51.imageshack.us/img51/4194/picture3to.png
You've probably got the "File Owner" (or the "Toolbar View") set to the wrong class. Interface Builder doesn't see any outlets or actions in the classes you have set currently.

How to access default NSOPenPanel actions?

Which actions are fired when user uses default NSOpenPanel from Main Menu? How to get the selection from it without creating NSOpenPanel in the code?
A.
Which actions are fired when user uses default NSOpenPanel from Main Menu?
There is no NSOpenPanel in the main menu. There is a menu item "Open…"
The automatism you might "feel" is implemented project dependently. But it is not there automatically. I think that some points has to be clearified:
a. Open Menu Item
The menu item "Open…" sends and only sends the action message openDocument: to the first responder. "Open…" does not open a panel, window dialog or $whatever.
Please get some information about first responders and the responder chain. It is a pity, that even the responder chain is one of the core concept of Cocoa, it is very unknown.
b. Open Panel
If you choosed to have a document based application, when you created the project, some additions are made to your project. In particular,
An instance of NSDocumentController is instantiated automatically.
This instance becomes a part of the responder chain.
Since NSDocumentController implements -openDocument:, it will catch the action message and
run an open panel
creates an instance of NSDocument. (More precise: of the subclass you selected as the document class.)
B.
How to get the selection from it without creating NSOpenPanel in the code?
Create a document-based app and let Cocoa do what it has to do. The base implementation of Cocoa matches 99 % of the cases and can be customized highly.
Do not create a document-based app: Handle the action message yourself, open a open panel yourself, after finishing that, create the instance of a document class and so on.