In article <6d6dnSly0L5RWr3VnZ2dnUVZ_qKgnZ2d@[EMAIL PROTECTED]
>,
Don Bruder <dakidd@[EMAIL PROTECTED]
> wrote:
> One of these things consistently pukes...
>
> Forgive blown line ends in the code that follows... It's cut-n-pasted
> directly from the project,
Which puts you one step ahead of half the people who ask for help.
> and the newsreader isn't too good at wrapping Objective-C!
>
> In the code that follows, if "TESTING" = 1, I get the expected result:
> The instance variable (declared as "NSMutableData *Buffer;" in my .h
> file) Buffer comes back filled with the HTML from MyURL.
>
> If "TESTING" !=1, Buffer comes back filled with random garbage.
>
> Likewise, when the first version gets used, the local NSData (Note NOT
> mutable) TheData variable is loaded with the HTML that comes from MyURL,
> but when the second version is used, TheData contains random garbage.
My first thought is that you're sort of overcomplicating things or
reading things backwards. The issue is that [NSData
dataWithContentsOfURL:MyURL] is not returning what you expect.
Everything after that - in particular the fact that Buffer comes out
wrong - is an obvious result.
Out of curiosity, are the first two bytes that you get back in the
second case 1F and 8B?
If so, you appear to have run across a bug that was introduced 4+ years
ago:
<http://www.cocoabuilder.com/archive/message/cocoa/2004/3/22/102280>
BTW: You really should avoid using synchronous downloads if you can.
BTW2: In case one, these two lines are wrong:
NSError *TheError = [NSError alloc];
NSURLResponse *TheResponse = [NSURLResponse alloc];
You should never alloc without a subsequent init.... More im****tantly,
in the specific way you're using them, you should initialize the
variables to nil instead of allocating space; they're output arguments.
What you've got leaks.
--
"Harry?" Ron's voice was a mere whisper. "Do you smell something ...
burning?"
- Harry Potter and the Odor of the Phoenix


|