What is [NSURL length]: an unrecognized selector sent to instance 0x1001c0360 means

I am trying to get example code paired with Cocoa's interface (it was written using Carbon); however, when I tried to replace

 err = ExtAudioFileCreateNew(&inParentDirectory, inFileName, kAudioFileM4AType, inASBD, NULL, &fOutputAudioFile);

with

err = ExtAudioFileCreateWithURL(CFURLCreateWithString(NULL,(CFStringRef)inFileName,NULL),kAudioFileM4AType,inASBD, NULL,kAudioFileFlags_EraseFile, &fOutputAudioFile);

I started getting these exceptions

2011-09-25 10: 27: 31.701 tester [1120: a0f] - [NSURL length]: unrecognized selector sent to instance 0x1001c0360 2011-09-25 10: 27: 31.701 tester [1120: a0f] - [NSURL length]: unrecognized selector sent to instance 0x1001c0360.

I examined several other questions and answers, and in all these cases the problem was with the transfer NSURLwhen expected NSString; however, I cannot find where / if I do this. I looked through the documentation and, as far as I can tell, with very limited knowledge of the Apple API. I am not doing anything bad.

Any help would be greatly appreciated.

+5
source share
3 answers

The error message is pretty clear. NSURLthe class does not have an instance method -length.

Have you tried creating an object NSURLwith Objective-C syntax and dropping it to CFURLRef?

+1
source

Maybe you can help, I had the same problem

UIImage :

[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]]];

[NSString stringWithFormat:]

NSString *urlStr =[NSString stringWithFormat:@"%@", [_photosURLs objectAtIndex:indexPath.row]];
NSURL *url = [NSURL URLWithString:urlStr];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
+10

I had the same issue when I was getting a url from a string, like [NSString stringWithFormat:@"%@Activity/GetBudget/%@",self.baseURL,activityID]

and I resolved it by calling absoluteString

like this

[[NSString stringWithFormat:@"%@Activity/GetBudget/%@",self.baseURL,activityID] absoluteString]

0
source

All Articles