开发者

What does -[NSURL length]: unrecognized selector sent to instance 0x1001c0360 mean

I've been trying to get some example code interfaced with a Cocoa interface(It had been written using Carbon); however, when I attempted 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 to get these exceptions

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

I've looked at several other questions and answers and in all of those cases the problem was related to a NSURL being passed when a NSString was expected; however, I can't find where/if I'm doing that. I've looked at the documentation and as far as I can tell with my extremely limited knowledge of Apple's APIs. I'm not doing anything wrong.

Any help would be greatly appreciated.


May be help you, i had same problem

I was trying to make UIImage from :

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

Then its solved with by making string with [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];


The error message is pretty clear. NSURL class does not have a -length instance method.

Have you tried to create the NSURL object with Objective-C syntax and cast it to CFURLRef?


I had the same issue while getting url from 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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜