I have a simple tabbar app
I have created a XIB file and assigned it to a tab, and when I touch the tab, it accurately switches
I added a simple IBAction
in Tab1.h
-(IBAction)pleasebeep:(id)sender;
in Tab1.m
-(IBAction)pleasebeep:(id)sender
{
NSLog(#"honk");
}
In interface builder I have created a button and linked it to the Owner and action "pleasebeep"
It compiles and launches.
When I click the button, the app crashes and I get a "-[UIViewController pleasebeep:]: unrecognized selector sent to instance 0x7b975c0
2011-10-06 04:32:25.648 FirstProject[8029:11903] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController pleasebeep:]: unrecognized selector sent to instance 0x7b975c0'
* First throw call stack:
(0x12de082 0x146fd0a 0x12dfd1d 0x1244f70 0x1244d52 0x12dfef9 0x37c542 0x37c4da 0x421576 0x421a3f 0x420cfe 0x3a1810 0x3a1a36 0x388234 0x37ba29 0x1ece10d 0x12b21f5 0x12170a2 0x121598a 0x1214e34 0x1214d4b 0x1ecc9dd 0x1eccaa2 0x379a1b 0x2749 0x26c5)
terminate called throwing an exceptionCurrent language: auto; currently objective-c"
Any idea where to hunt for the problem?
Have you set the right Custom Class to the File's Owner? Maybe it's still set to the default class 'UIViewController'
Related
I am developing an application using Xcode 7 and Swift 2. I recently discovered an error in my code. In the debugger log (I think that is what it is called) , it printed this:
[AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=7 "Ad was unloaded from this banner" UserInfo={ADInternalErrorCode=7, NSLocalizedFailureReason=Ad was unloaded from this banner, ADInternalErrorDomain=ADErrorDomain}
I did some research and found out that I needed this code:
iAdBannerView.delegate = self
In my viewDidLoad method. I tried it, and I no longer recieved the error. However, I have two viewControllers. Both contain iAds. In the original view controller, ViewController.swift, the code workds. In the view controller that I later added, AboutViewContoller, I get this error:
Cannot assign a value of type 'AboutViewController' to a value of type 'ADBannerViewDelegate?"
Could someone please show me my error in my code?
Earlier, I had:
class AboutViewController: UIViewController {
I forgot the ADBannerViewDelegate. The correct code is:
class AboutViewController: UIViewController, ADBannerViewDelegate {
Thanks to Charles A. and Daniel Storm for helping out!
In the course of the development of a Resharper plugin, I'd like to show an error message to a user when they incorrectly use a context action. Is there a way to pop up a window in Visual Studio to communicate the Resharper exception message to the user? I'm developing a plugin with Resharper 8 and VS 2012
You can always use MessageBox - ReSharper also provides a MessageBox static class that provides a number of helper methods to make it easy to display what you want. It also allows for adding "message box handlers" so that you don't actually display a message box during testing.
Alternatively, if you're creating a context action, and you're (indirectly) deriving from BulbActionBase, your ExecutePsiTransaction method (which should do all the work) can return an Action<ITextControl>. This allows you to return an action that will execute after the quick fix/context action has completed, which can be anything from positioning the caret, changing the selection, executing a template or showing a tooltip as an error.
You can return something like this:
return tc => myLocks.QueueReadLock("MyContextAction", () => {
myTooltipManager.Show("Something went wrong!",
lifetime => new TextControlPopupWindowContext(lifetime, tc, myLocks, myActionManager);
});
This is using a number of fields: IShellLocks myLocks, ITooltipManager myTooltipManager and IActionManager myActionManager. These can be injected into a component's constructor by ReSharper's component model, or you can get them with solution.GetComponent<IShellLocks>, etc.
What's happening is that you're returning an action that takes in an ITextControl, and which immediately queues up another action to run, on the UI thread, with the read lock taken. This second action tells the tooltip manager to show an error message as a tooltip, and provides a factory method for creating a popup window context (the lifetime parameter is created and disposed by the call to Show, and allows for cleanup of the context).
You could also look at the ShowAtCaret extension method to ITooltipManager - I can't remember offhand where Show will place the tooltip.
I am working on an app where the user has the possibility to add products and those products are then displayed in a TableView. I created a TableViewController with static cells and two sections and I want to hook the cell in the second section with another TableViewController.
I dragged the TableViewController from the object library, embedded it in a navigation controller and made a push segue from the cell to the NavigationController but when I try to run the app I get the following error message in the output window:
2013-03-20 09:55:32.981 STAM[725:c07] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
First throw call stack:
(0x1d04012 0x11e8e7e 0x22a5b0 0x22a098 0x585da3 0x577ad9 0x577b54 0x1df899 0x1dfb3d 0xbe6e83 0x1cc3376 0x1cc2e06 0x1caaa82 0x1ca9f44 0x1ca9e1b 0x1f3c7e3 0x1f3c668 0x13065c 0x2a6d 0x2995)
libc++abi.dylib: terminate called throwing an exception
Here's a screenshot form my storyboard.
Thank you very much!
Granit
Your UINavigationController is at the wrong place. It should be before the UITableViewController.
You can select the UITableViewController from story board then from menu: Editor > Embed In > Navigation Controller.
You can get more info about the navigation stack from the reference guide.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html
Using bindings, how can I make NSButton invoke a method in my AppDelegate class? I tried setting the target sleector to buttonClicked: but in console it gives me:
unrecognized selector sent to instance
0x100105060
Also there's no place in bindings to specify which instance to look for the method in so how can I set it to AppDelegate?
Thanks.
As Simon says, bindings are not appropriate for this situation. Bindings allow you to "bind" UI elements to a data source. In your situation, you need an action - not a binding.
You are getting the error because you haven't actually defined the buttonClicked action. Thus, make sure you declare it with something like in your AppDelegate.m:
- (IBAction) buttonClicked:(id) sender;
Then set the action via interface builder by first setting the "FilesOwner" to the AppDelegate and then connecting the onTouchUpInside event to the action "buttonClicked".
Hope this helps!
Bindings are used to synchronize a variable and an element of the interface.
In your case, I guess an action would be better. Declare your method with IBAction and control-drag from your button to your AppDelegate instance in Interface Builder to be able to select the action.
I'm am a beginner in mac os x development and am trying to get started with all this.
Here is my problem : I've create a non-document based cocoa app using core data as storage. I've added an entity and attributes to the xdatamodel. In IB i've created an NSArrayController and linked it properly. I've created an nstableview binded to the nsarraycontroller. Next I added a button linked to nsarraycontroller with the " add: " method.
When I try it out, I can add and edit the items in the table.
Here comes the problem: Core data is supposed to save everything automatically, but to make sure i linked the "save" button in the menu to the appdelegate and to the " file's owner" , first responder, application... everything possible ( with both " save :" and " saveaction:" methods ).
And still it doesn't save when clicking save: when I restart the cell created ( and renamed ) are gone.
And also, I didn't even edit the source code yet; core data for such simple tasks is supposed to only need Interface builder.
Please help me for this, I haven't found any threads resolving this problem.
Thank you in advance.
To save the changes, you'll have to call save: on the managed object context.
If you look at the CoreDataBooks example, you'll see how they call it like this as a result of the user pressing save:
- (IBAction)saveAction:(id)sender {
NSError *error;
if (![[self managedObjectContext] save:&error]) {
// Update to handle the error appropriately.
NSLog(#"Unresolved error %#, %#", error, [error userInfo]);
abort(); // Fail
}
}