Getting the error (breakpoint) "Thread 1: signal SIGBRT" - iphone

While trying to run my tab-bar app with many different features such as UITableView and mapview with a annotation, I recently added a webview on my first tab in my firstviewcontroller. As far as I know, there's nothing wrong with the coding there, though ever since I tried adding the webview on my first tab I keep getting the breakpoint/error while trying to run the app : Thread 1: signal SIGBRT.
I've read around some, and someone said that if I change mi xib file /storyboard's deployment to iOS 5.0 instead of 6.0 (wich I'm currently using) and not having "Use Autolayout" checked it should get rid of it. Though It didn't. Any thoughts or solutions to this?
Here's the coding for my firstviewcontroller.h
#import <UIKit/UIKit.h>
#interface FirstViewController : UIViewController
#property (weak, nonatomic) IBOutlet UIWebView *webView;
#end
firstviewcontroller.m
#import "FirstViewController.h"
#interface FirstViewController ()
#end
#implementation FirstViewController
#synthesize webView;
- (void)viewDidLoad
{
NSString *website = #"http://www.google.com";
NSURL *url = [NSURL URLWithString:website];
NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestUrl];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#end
main.m :
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); // <--- HERE's where it says SIGBRT
}
}
All output:
2013-01-04 11:27:06.697 My Corp[784:13d03] Unknown class ViewController in Interface Builder file.
2013-01-04 11:27:06.716 My Corp[784:13d03] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FirstViewController 0x808fbf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key myWebView.'
*** First throw call stack:
(0x1800012 0x11c5e7e 0x1888fb1 0xc72711 0xbf3ec8 0xbf39b7 0xc1e428 0x32a0cc 0x11d9663 0x17fb45a 0x328bcf 0x1ede37 0x1ee418 0x1ee648 0x1ee882 0x20fed9 0x20fd14 0x20e1ea 0x20e06c 0x20c1cc 0x20c9b6 0x1f0753 0x1f0a7b 0x1f1964 0x154877 0x15b5a3 0x153eed 0x13db56 0x13ddbf 0x13df55 0x146f67 0x10afcc 0x10bfab 0x11d315 0x11e24b 0x10fcf8 0x1cc9df9 0x1cc9ad0 0x1775bf5 0x1775962 0x17a6bb6 0x17a5f44 0x17a5e1b 0x10b7da 0x10d65c 0x289d 0x27c5)
libc++abi.dylib: terminate called throwing an exception
(lldb)

The mistake you have done was clearly stated in the crash report
[<FirstViewController 0x808fbf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key myWebView.'
To solve that go to your XIB of that Class right click on the File owner located on the left side pane of InterfaceBuilder. You will find an object with name myWebView with yellow warning icon, click remove on that outlet connection and compile your code. You have connected the outlet and later you remove the IBOutlet in the code and forget to remove the connection in the XIB.

set
UIWebViewDelegate in .h file and in xib attach delegate of webview

Related

Mapkit application crashes, what am i doing wrong?(iOS)

I am new to programming, and i decided to start off with using Xcode and Obj-C.
I'm making a tabbed application where the second view controller contains the map that is supposed to zoom to the users location. I guess i just cant get the code right, when i try to run the app in iOS simulator it just crashes when i open the second view controller.
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Within #autoreleasepool i get a "Thread 1: signal SIGABRT" on every run.
This is the output i get when i open the second view controller
2013-08-05 21:31:26.271 placerate[56730:c07] Couldn't find default.styleproto in framework
2013-08-05 21:31:26.277 placerate[56730:c07] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x98a1120> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mapView.'
*** First throw call stack:
(0x16b3012 0x14d8e7e 0x173bfb1 0xf84e41 0xf065f8 0xf060e7 0xf30b58 0x63a019 0x14ec663 0x16ae45a 0x638b1c 0x4fd7e7 0x4fddc8 0x4fdff8 0x4fe232 0x51f8c9 0x51f704 0x51dbda 0x51da5c 0x51f647 0x14ec705 0x4202c0 0x420258 0x642ff4 0x14ec705 0x4202c0 0x420258 0x4e1021 0x4e157f 0x4e1056 0x646af9 0x14ec705 0x4202c0 0x420258 0x4e1021 0x4e157f 0x4e06e8 0x44fcef 0x44ff02 0x42dd4a 0x41f698 0x2500df9 0x2500ad0 0x1628bf5 0x1628962 0x1659bb6 0x1658f44 0x1658e1b 0x24ff7e3 0x24ff668 0x41cffc 0x22fd 0x2225)
libc++abi.dylib: terminate called throwing an exception
(lldb)
This is the output under the "Auto" pane :
argc = (int)1
argv = (char **)0xbffff3b4
SecondViewController.h :
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface SecondViewController : UIViewController
<MKMapViewDelegate>
#property (strong, nonatomic) IBOutlet MKMapView *mapView;
- (IBAction)zoomIn:(id)sender;
- (IBAction)changeMapType:(id)sender;
#end
SecondViewController.m :
#import "SecondViewController.h"
#interface SecondViewController ()
#end
#implementation SecondViewController
- (IBAction)zoomIn:(id)sender {
MKUserLocation *userLocation = _mapView.userLocation;
MKCoordinateRegion region =
MKCoordinateRegionMakeWithDistance ( userLocation.location.coordinate, 50, 50);
[_mapView setRegion:region animated:NO];
}
- (IBAction)changeMapType:(id)sender {
if (_mapView.mapType == MKMapTypeStandard)
_mapView.mapType = MKMapTypeSatellite;
else
_mapView.mapType = MKMapTypeStandard;
}
- (void)mapView:(MKMapView *)mapView
didUpdateUserLocation:
(MKUserLocation *)userLocation
{
_mapView.centerCoordinate =
userLocation.location.coordinate;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_mapView.showsUserLocation = YES;
_mapView.delegate = self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
I've followed a tutorial on the matter - so as you might have noticed, this is pretty greek to me. I'll be happy to supply additional information on the problem. Thanks in advance,
kind regards
Yngve
EDIT:
I created a new project and i recycled some of the code, for some reason it just worked. I believe the different answers and solutions gave me a heads up to pay more attention when working with programming. This is my first project, so i expect i might run into some more trouble, thank you all for taking the time to answer my question. (I actually find code exciting now)
Yngve
Looks like you just need to set the class of the second view controller to SecondViewController in the inspector pane of your storyboard. It's still set to a stock UIViewController.
Sounds like the missing styleproto files might be the issue, see this SO answer: iOS6 Simulator MKMapKit "Couldn't find default.styleproto in framework"
Are you using a Storyboard or NIB? If so, you might want to see this SO answer and make sure you set the right custom class in IB: NSInvalidArgumentException isKindOfClass
For me mapView will sometimes throw exceptions in the simulator when you execute this line of code
_mapView.showsUserLocation = YES;
Restarting Xcode and clearing derived data is what fixes it for me when it gets in this state. Resetting simulator does nothing.

IOS Segue - Terminating app due to uncaught exception 'NSGeneric Exception'

Storyboard screenshot
In the Xcode 4.6 Storyboard i've 2 ViewControlers, one which holds the buttons and the other a labelView, passing a string "Home Tapped" on the tap of the home button
Heres the ViewController.m code
#import "ViewController.h"
#import "ViewController2.h"
#interface ViewController ()
#end
#implementation ViewController
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:#"Home"])
{
NSString *message = #"Tapped on home";
ViewController2 *vc = [segue destinationViewController];
vc.labelString = message;
}
}
ViewController2.h
#import <UIKit/UIKit.h>
#interface ViewController2 : UITableViewController
#property(nonatomic,strong) UILabel *mylabel;
#property(nonatomic,strong) NSString *labelString;
#end
And the error
Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'Home'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
*** First throw call stack:
(0x1c91012 0x10cee7e 0x468f31 0x45ab99 0x45ac14 0x10e2705 0x162c0 0x16258 0xd7021 0xd757f 0xd66e8 0x45cef 0x45f02 0x23d4a 0x15698 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x12ffc 0x28dd 0x2805)
libc++abi.dylib: terminate called throwing an exception
(lldb)
You need to make your NavigationController the entry point for your storyboard. Right now it is View Controller, which is indicated by the arrow pointing to it with no source.

Unrecognized selector sent to instance" problem

my code broke somewhere along the way, and crashes when using the navigation bar buttons.
Error message:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView newMemoViewController:didAddMemo:]: unrecognized selector sent to instance 0x5b55a60'
When debugging, the program does run the cancel method, and throws an exception at the #synthesize line. However, I cannot see anything wrong with it.
The symptoms are identical, so I am including the relevant code only for the Cancel button:
NewMemoViewController.h
#import <UIKit/UIKit.h>
#protocol NewMemoDelegate;
#class AKVoiceMemo;
#interface NewMemoViewController : UIViewController {
#private
AKVoiceMemo *voiceMemo;
id <NewMemoDelegate> delegate;
}
#property (nonatomic, retain) AKVoiceMemo *voiceMemo;
#property (nonatomic, assign) id <NewMemoDelegate> delegate;
#end
#protocol NewMemoDelegate <NSObject>
- (void)newMemoViewController:(NewMemoViewController *)newMemoViewController didAddMemo:(AKVoiceMemo *)voiceMemo;
#end
NewMemoViewController.m
#import "NewMemoViewController.h"
#synthesize delegate;
- (void)viewDidLoad {
UIBarButtonItem *cancelButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Cancel" style:UIBarButtonItemStyleBordered target:self action:#selector(cancel)];
self.navigationItem.leftBarButtonItem = cancelButtonItem;
[cancelButtonItem release];
}
- (void)cancel {
[self.delegate newMemoViewController:self didAddMemo:nil];
}
Your help would be appreciated.
Edit: the delegate is the RootViewController:
- (void)newMemoViewController:(NewMemoViewController *)newMemoViewController didAddMemo:(AKVoiceMemo *)voiceMemo {
if (voiceMemo){
// Show the note in a new view controller
// TODO: Implement this
}
[self dismissModalViewControllerAnimated:YES];
}
You're probably setting the delegate of NewMemoViewController to a UIView object instead of an object that implements the NewMemoDelegate protocol.
The error message is telling you that a newMemoViewController:didAddMemo: message was sent to a UIView object and the UIView object didn't know what to do with it. Since your cancel method calls newMemoViewController:didAddMemo: on the delegate, it is the delegate which is the UIView object that doesn't recognize the newMemoViewController:didAddMemo: message. In other words, your delegate is a UIView and it doesn't implement the NewMemoDelegate protocol.
If you are correctly setting the delegate, then #jtbandes makes a great point: The delegate is probably being released and a UIView object is taking over the same memory location, thus "becoming" the delegate by accident. You're doing the right thing by using the assign attribute for your delegate; that's fairly standard Cocoa practice. However, you do need to make sure that the delegate is retained by another object, and that object needs to make sure that the delegate sticks around as long as NewMemoViewController needs it to.
I'm guessing you've over-released the delegate. I notice you have #property (assign) ... delegate;. This means that whenever you set the delegate, that object must be retained by something else as well.
The other possibility is the delegate is actually a UIView, but I'm guessing it's the other case.

ModalViewController delegate confusion

I need to present a modal view controller and be notified when it is dismissed or notified that I need to dismiss it, looking here I am still confused:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW14
I have my mainViewController and myModalView controller and I have the following code that needs to be implemented but not sure where - first up delegate protocal:
#protocol DataSyncDelegate <NSObject>
-(void) doneWithSync;
#end
which controller.h does this go in? I am assuming my modalViewController.h
second is my implementation:
-(void) doneWithSync {
[self dismissModalViewControllerAnimated:YES];
}
which controller.m does this go in? I am assuming my mainViewController.m
I also have the delegate properties that needs to be aded:
id delegate;
#property (nonatomic, retain) id delegate;
which controller.m does this need to go in? I am assuming my modalViewController.h
and here is how I am presenting the modalViewController from my MainViewController:
DataSyncViewController *dataSyncViewController = [[DataSyncViewController alloc] initWithOptions:FALSE];
dataSyncViewController.delegate = self;
[self presentModalViewController:dataSyncViewController animated:NO];
[dataSyncViewController release];
As of right now this gives me the following error:
-[DataSyncViewController setDelegate:]: unrecognized selector sent to instance 0x5952e20
What am I missing here?
EDIT - HERE IS MY MODAL VIEW CONTROLLER .H
#import <UIKit/UIKit.h>
#protocol DataSyncDelegate
-(void) doneWithSync;
#end
#interface DataSyncViewController : UIViewController {
id <DataSyncDelegate> delegate;
}
#property (nonatomic, retain) id <DataSyncDelegate> delegate;
#end
EDIT - MAIN VIEW CONTROLLER .H AND .M
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "DataSyncViewController.h"
#interface LoginViewController : UIViewController <DataSyncDelegate>{
}
#end
HERE IS THE CREATION OF THE MODAL:
DataSyncViewController *dataSyncViewController = [[DataSyncViewController alloc] initWithOptions:FALSE];
dataSyncViewController.delegate = self;
[self presentModalViewController:dataSyncViewController animated:NO];
[dataSyncViewController release];
HERE IS MY IMPLEMENTATION OF THE DELEGATE:
-(void) doneWithSync {
[self dismissModalViewControllerAnimated:YES];
}
And now everything looks to wire up correctly in the compiler but I get the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[DataSyncViewController setDelegate:]: unrecognized selector sent to instance 0x59e4b40'
Your main view controller IS the delegate and should implement the protocol. Your modalView has a delegate that it calls when it is being dismissed.

Pushing a UIViewController doesn't work with connections

Alright, in my rootViewController, I am able to push another viewController that I defined myself onto the screen. However, when I make any connections between that viewController and its own .h file, the program just hangs and crashes, giving me this error:
2010-06-04 15:36:13.944 pooldocfinal[11971:20b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key label1.'
That happens when i don't connect anything besides that one UILabel. Here is the code I use to declare/push the view (named balanceViewController):
- (IBAction) pushedBalanceButton
{
balanceViewController *controller = [[balanceViewController alloc] initWithNibName:#"balanceViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
And here is the .h file of the view that I am pushing, it has only one thing in it:
#import <UIKit/UIKit.h>
#interface balanceViewController : UIViewController {
IBOutlet UILabel *label1;
}
#end
And like I said, everything works unless I actually make a connection in Interface Builder between anything in balanceViewController.xib and balanceViewController.h (in this case, it is the one UILabel object).
You should alloc a balanceViewController, not a UIViewController.
I believe if you have an IBOutlet, you need to define getters/setters. That's what Key Value coding compliant means. You can do this via #property statements and #synthesize statements, or manually if you so choose.
#interface balanceViewController : UIViewController {
IBOutlet UILabel *label1;
}
#property (nonatomic, retain) IBOutlet UILabel *label1;
#end
Then add
#synthesize label1;
to your implementation
EDIT - PS, don't forget to [label1 release] in your dealloc method