Using NSOutputStream outputStreamWithURL with a custom URLprotocol

I'm writing a custom URL protocol (subclass of NSURLProtocol) to deal with local files that need a special way of reading and writing. No problem when reading: I can successfully create an URL like -for example- "my-funny-file-protocol://...." and all the things work fine.

The problem arises when I try to write to this kind of URL's. In particular, I need to use an NSOutputStream, so I need to call something like:

NSString *urlString = [NSString stringWithFormat:@"my-funny-file-protocol://%@", path];
NSURL *url = [NSURL URLWithString:urlString];
NSOutputStream *writer = [NSOutputStream outputStreamWithURL:url append:NO];

No exception raises, no logs on the console but the result is always nil . The same file works, if I use a standard file: protocol:

NSString *urlString = [NSString stringWithFormat:@"file://%@", path];

Why? In fact the NSURLProtocol documentation does not explain well my case. Perhaps I'm missing someting in my URLProtocol implementation... but what?

Many thanks in advance,

Rob

链接地址: http://www.djcxy.com/p/34836.html

上一篇: NSURLProtocol没有完成NSURLRequest

下一篇: 使用带有自定义URL协议的NSOutputStream outputStreamWithURL