Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > Re: (Obj-C) One...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 6 Topic 3733 of 3882
Post > Topic >>

Re: (Obj-C) One of these things is not like the other...

by Gregory Weston <uce@[EMAIL PROTECTED] > May 6, 2008 at 06:52 PM

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
 




 6 Posts in Topic:
(Obj-C) One of these things is not like the other...
Don Bruder <dakidd@[EM  2008-05-06 14:04:10 
Re: (Obj-C) One of these things is not like the other...
Gregory Weston <uce@[E  2008-05-06 18:52:29 
Re: (Obj-C) One of these things is not like the other...
Don Bruder <dakidd@[EM  2008-05-06 18:57:46 
Re: (Obj-C) One of these things is not like the other...
David Phillip Oster <o  2008-05-06 20:27:56 
Re: (Obj-C) One of these things is not like the other...
David Phillip Oster <o  2008-05-06 20:33:31 
Re: (Obj-C) One of these things is not like the other...
David Phillip Oster <o  2008-05-06 23:38:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 11:13:03 CST 2008.