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]];
Related
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:.
I'm trying to parse this JSON Array:
http://www.ifanatic.hu/api/get_recent_posts/?dev=1
But I get this error:
2012-07-15 22:31:59.038 JSONTest[610:f803] -[__NSCFDictionary indexOfObject:]: unrecognized selector sent to instance 0x6a92850
2012-07-15 22:31:59.040 JSONTest[610:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary indexOfObject:]: unrecognized selector sent to instance 0x6a92850'
*** First throw call stack:
(0x13d7052 0x1568d0a 0x13d8ced 0x133df00 0x133dce2 0x236b 0xa23a59 0xa21e94 0xa22eb7 0xa21e4f 0xa21fd5 0x966f6a 0x3989bbd 0x3a565ea 0x3980298 0x3a5616b 0x3980137 0x13ab97f 0x130eb73 0x130e454 0x130ddb4 0x130dccb 0x12c0879 0x12c093e 0x2ea9b 0x1cb8 0x1c15)
terminate called throwing an exception
Here is my source:
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSArray* latestPosts = [responseString JSONValue];
NSDictionary* post = [latestPosts objectAtIndex:[latestPosts indexOfObject:0]];
NSString* title = [post objectForKey:#"title"];
label.text = [NSString stringWithFormat:#"Title: %#", title];
That JSON object's root element is translated to an NSDictionary when parsing the JSON. And NSDictionary doesn't respond to the
indexOfObject:
message. What you need to do is to use:
NSDictionary *post = [[latestPosts objectForKey:#"posts"] objectAtIndex:0];
etc.
I created a static library for iOS. The library uses core data to store some objects fetched from the internet.
When I try to use my library in a standard iOS project, it seems like it can't create any instances of core data entities. I have the following error :
-[NSManagedObject initWithDictionary:]: unrecognized selector sent to instance 0x6e5d4e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObject initWithDictionary:]: unrecognized selector sent to instance 0x6e5d4e0'
initWithDictionary is actually a method I call on a core data entity object.
Then I tried to create the managed object model out of the library like shown here : core data in a static library for the iPhone
NSMutableSet *allBundles = [[[NSMutableSet alloc] init] autorelease];
[allBundles addObjectsFromArray: [NSBundle allBundles]];
[allBundles addObjectsFromArray: [NSBundle allFrameworks]];
managedObjectModel = [NSManagedObjectModel mergedModelFromBundles: [allBundles allObjects]];
OR
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:#"Model" withExtension:#"momd"];
managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
but it didn't work. I have the following error when I try to instantiate a class of my library giving it the managed object model :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LauncherViewController initWithNibName:managedObjectModel:andKey:]: unrecognized selector sent to instance 0x6b94db0'
If I try this : core data in a static library for the iPhone , I get this error :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
Please help me, I really don't know what to do anymore...
after nsXml pasring value of my NSMutable array AB
=\n\n\n\thttp://xyz.com/uploads/resto_6298__20091209#1621_250.JPG\n\thttp://xyz.com/uploads/resto_6298__200912099_2_250.JPG\n"
now i am doing this to make this url working
NSString *sw=AB;
NSArray *strings = [sw componentsSeparatedByString: #"\n\t"];
NSLog(#"what I have %#",strings);
but my app always crash and i am getting this error
[NSCFArray componentsSeparatedByString:]: unrecognized selector sent to instance 0x1b28b0
2010-10-05 10:17:31.382 Wat2Eat[2311:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray componentsSeparatedByString:]: unrecognized selector sent to instance 0x1b28b0'
how to parse this AB so that i can extract exact URL
NSString *sw=AB;
AB is an NSMutableArray?
the compiler should print a warning if you try to do this. You tried to assign an NSArray to an NSString. This will not work.
Did you mean NSString *sw = [AB objectAtIndex:foo]; ?
I've built an XML parser in Objective-C and the message objectForKey throws an NSException but I don't know why.
aPicture = [[Picture alloc] init];
aPicture.pictureID = [[attributeDict objectForKey:#"id"] integerValue];
Here is the message of the exception that i don't understand:
2010-08-09 21:27:32.223 rh[6375:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Picture setPictureID:]: unrecognized selector sent to instance 0x592e0b0'
After a long search i got my mistake...
I have forgotton to synthezise the pictureID selector.
....