SIGABRT Error After Snippets Added to Source Code - iphone

So after adding the following snippets to my source code, the application refuses to run and gives me a SIGABRT error:
CIALBrowserViewController.h
UIBarButtonItem *homeButtonItem;
CIALBrowserViewController.m
#interface CIALBrowserViewController ()
- (void)goHome:(id)sender;
..
homeButtonItem = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"home.png"]
style:UIBarButtonItemStylePlain
target:self
action:#selector(goHome:)] autorelease];
..
- (void)goHome:(id)sender {
NSURL *url = [NSURL URLWithString:#"http://google.ca/"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
The SIGABRT Error
2012-06-17 14:15:15.130 CIALBrowser[1753:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x354fa88f 0x378a1259 0x3544f1d7 0x5f8b 0x32f67c17 0x2a67 0x32f66cab 0x32f607dd 0x32f2eac3 0x32f2e567 0x32f2df3b 0x370ed22b 0x354ce523 0x354ce4c5 0x354cd313 0x354504a5 0x3545036d 0x32f5f86b 0x32f5ccd5 0x28df 0x2878)
terminate called throwing an exception(lldb)
Heres the full source code to CIALBrowserViewController.m: http://pastebin.com/uuUgi7Dc

In else section of if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad), there is no homeButtonItem alloced or inited, so homeButtonItem is nil. Then [buttons addObject:homeButtonItem]; will crash, because you are adding a nil object to array.

THe SIGABRT error suggests that somewhere in your code you use the method insertObject:atIndex: and use nil as the first parameter, which is not allowed, throwing an error. I went to your code on paste bin and did not see that method called there, so the error is likely in another file.
Hope this helps!

Related

iPhone simulator continues to fail loading a webpage with the error sigabrt

I'm building a web browser from scratch and most everything works except for the most important thing. The browser will fail with the error sigabrt and, while I'm new to iPhone programming, I'm pretty sure this means that I'm not sending the URL correctly.
This is the code for loading the webpage by pressing a button.
- (IBAction)getURLButton:(NSString *)aString {
NSURL *URL = [NSURL URLWithString:aString];
NSURLRequest *URLRequest = [NSURLRequest requestWithURL:URL];
BOOL load = [addressBar webView: (goButton) shouldStartLoadWithRequest:URLRequest navigationType:UIWebViewNavigationTypeFormSubmitted];
if (load) {
error = nil;
[goButton loadRequest:URLRequest];
//currentURLString = [UIWebView stringByEvaluatingJavaScriptFromString:#"document.location.href"];
//It's not in Xcode? It continues to get an error after I write the above statement.
} else {
NSString *message = NSURLErrorFailingURLErrorKey;
NSLog(#"%#",message);
}
}
And this is the error message:
2013-02-14 16:49:28.724 WebBrowser[1265:c07] -[ViewController getURL:]: unrecognized selector sent to instance 0x716f1d0
2013-02-14 16:49:28.727 WebBrowser[1265:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController getURL:]: unrecognized selector sent to instance 0x716f1d0'
I know the errors there somewhere, I just don't know where. Help?
2013-02-14 16:49:28.724 WebBrowser[1265:c07] -[ViewController getURL:]: unrecognized selector sent to instance 0x716f1d0
2013-02-14 16:49:28.727 WebBrowser[1265:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController getURL:]: unrecognized selector sent to instance 0x716f1d0'
If you see your exception you are calling getURL: where as your method name is getURLButton:.

NSURL getFileSystemRepresentation:maxLength

Im having error with this code
NSString *theURL = #"http://www.w3schools.com/xml/cd_catalog.xml";
NSData *theData=[NSData dataWithContentsOfFile:[NSURL URLWithString:theURL]];
NSDictionary *theDic=[XMLReader dictionaryForXMLData:theData error:nil];
error is
2013-02-10 00:39:05.113 MyXml[4139:c07] -[NSURL getFileSystemRepresentation:maxLength:]: unrecognized selector sent to instance 0x7139670
2013-02-10 00:39:05.115 MyXml[4139:c07] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[NSURL getFileSystemRepresentation:maxLength:]: unrecognized selector sent to instance 0x7139670'
*** First throw call stack:
(0x1c96012 0x10d3e7e 0x1d214bd 0x1c85bbc 0x1c8594e 0xad3ee4 0xad3e92 0xad3de2 0xaf2336 0x2bb8 0x15157 0x15747 0x1694b 0x27cb5 0x28beb 0x1a698 0x1bf1df9 0x1bf1ad0 0x1c0bbf5 0x1c0b962 0x1c3cbb6 0x1c3bf44 0x1c3be1b 0x1617a 0x17ffc 0x295d 0x2885)
libc++abi.dylib: terminate called throwing an exception
it is giving error because you are initing NSData with file by help of dataWithContentsOfFile, but actually you are giving URL to the NSData for initing it. because of this your code indirectly calling method of file getFileSystemRepresentation:maxLength: on NSURL ,thats why it is giving error-Unknown selector.
use this dataWithContentsOfURL instead of dataWithContentsOfFile
NSString *theURL = #"http://www.w3schools.com/xml/cd_catalog.xml";
NSData *theData=[NSData dataWithContentsOfURL:[NSURL URLWithString:theURL]];

The app can not launch when I cancel the NKAssetDownload

I m working on a app with the NewsstandKit.frame work.
There was the NKAssetDownload request:
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:5.0];
_assetDownload = [self.issue addAssetWithRequest:request];
[_assetDownload downloadWithDelegate:self];
And the way I stop/pause the downloading it to cancel the connect:
NSURLConnection *con = [[self.issue.downloadingAssets objectAtIndex:0] downloadWithDelegate:self];
[con cancel];
And then there becomes the question,when I run the app again, there will show the wrong information about:
-[NKAssetDownload cover]: unrecognized selector sent to instance 0x6c69fc0
2012-10-26 15:49:39.257 MyMagazineDemoV0.0.1[3872:fb03] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NKAssetDownload cover]: unrecognized selector sent to instance 0x6c69fc0'
* First throw call stack:
(0x18b1022 0x1a42cd6 0x18b2cbd 0x1817ed0 0x1817cb2 0x10405 0x1018d 0x12f0a 0x127f8 0x3a2a 0x3d999b 0x338401 0x338a46 0x254e 0x310386 0x311274 0x320183 0x320c38 0x314634 0x179bef5 0x1885195 0x17e9ff2 0x17e88da 0x17e7d84 0x17e7c9b 0x310c65 0x312626 0x2292 0x2205)
terminate called throwing an exception
I duno wut does it mean,cuz I can not find the method called"cover" in NKAssetDownload.
Could anybody help me?:)
The correct procedure to start the download is as follows:
currentIssue = [library addIssueWithName:issueName date:issueDate];
NSURLRequest *urlReq = [NSURLRequest requestWithURL:[NSURL URLWithString:file_Url]];
NKAssetDownload *asset = [currentIssue addAssetWithRequest:urlReq];
[asset downloadWithDelegate:self];
When removing an issue, you should also remove the issue from Newsstand library:
NKIssue *issueToRemove = [[NKLibrary sharedLibrary] issueWithName:issueName];
if (issueToRemove) {
[[NKLibrary sharedLibrary] removeIssue:issueToRemove];
}
In addition to this u have to implement the NSURLConnectionDownloadDelegate methods
(void)connection:(NSURLConnection *)connection didWriteData:(long long)bytesWritten totalBytesWritten:(long long)totalBytesWritten expectedTotalBytes:(long long)expectedTotalBytes
(void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *)destinationURL
Try this. This works without error.

ios memory leak

I have a method that sets up NSXMLParser with the correct data that I am pretty sure is causing a memory leak.
This is my first time using instriments to try and solve a memory leak and have got it down to the offending method..
by looking at the response caller value in instruments memory leak testing.
I am hoping you can tell me where the memory leak is here... because I release both myDataArray and parser... im just not sure where I am going wrong.. do I need to assign them nil also?
- (void)startTheParsingProcess:(NSData *)parserData
{
[myDataArray release]; // clears array for next time it is used.
myDataArray = [[NSMutableArray alloc] init];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:parserData]; //parserData passed to NSXMLParser delegate which starts the parsing process
[parser setDelegate:self];
[parser parse]; // starts the event-driven parsing operation.
[parser release];
}
any help would be appreciated.
UPDATE:
I have made the changes to my application and when I run it on the simulator I do not get any memory leak errors..
however if I run it on my phone get this in the console...
2011-10-19 11:22:05.673 code[1299:707] -[__NSCFType section]: unrecognized selector sent to instance 0x1b9b80
2011-10-19 11:22:05.683 code[1299:707] CoreAnimation: ignoring exception: -[__NSCFType section]: unrecognized selector sent to instance 0x1b9b80
2011-10-19 11:22:07.949 code[1299:707] -[__NSCFType row]: unrecognized selector sent to instance 0x1b9b80
2011-10-19 11:22:07.951 code[1299:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType row]: unrecognized selector sent to instance 0x1b9b80'
*** First throw call stack:
(0x35e9e8b3 0x366e61e5 0x35ea1acb 0x35ea0939 0x35dfb680 0x334a76cf 0x3353c713 0x30fd5 0x3352cd69 0x335a60ab 0x35cc32ab 0x35e72a57 0x35e726bd 0x35e71293 0x35df44e5 0x35df43ad 0x30fa4fed 0x334a7dc7 0x272f 0x26d8)
Try putting this in the .h
#property (nonatomic, retain) NSMutableArray *myDataArray
.m
#synthesize myDataArray
in the method...
- (void)startTheParsingProcess:(NSData *)parserData
{
self.myDataArray = [NSMutableArray arrayWithCapacity:8];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:parserData]; //parserData passed to NSXMLParser delegate which starts the parsing process
[parser setDelegate:self];
[parser parse]; // starts the event-driven parsing operation.
[parser release];
}

Core Data model Is throwing Exception

I am using core data in my app. My app was working fine.. I recently reset my simulator setting and now that app is throwing exception. I read all posts and clean my target also but it is not running ,,then I set breakPoint and found exception in last line of this code
- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel_ != nil) {
return managedObjectModel_;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:#"TouristGuide" withExtension:#"momd"];
managedObjectModel_ = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return managedObjectModel_;
}
This code is in my APPdelegate file.. And Exception is
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an
NSPersistentStoreCoordinator with a nil model'
As the error says, the model seems to be nil, or rather the modelURL. You can see this by adding NSLog(#"%#", modelURL), it will print (null).
Make sure that your model is really called TouristGuide and is in the mainBundle, i.e. gets added when building.