• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: JSONSerialization 'Garbage at end' error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JSONSerialization 'Garbage at end' error


  • Subject: Re: JSONSerialization 'Garbage at end' error
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 30 Apr 2014 16:27:18 -0700

On Apr 30, 2014, at 16:00 , Jonathan Hull <email@hidden> wrote:

> I also find that it is good practice to set variables returned by reference to nil before passing them.
>
> NSError *error = nil;
>
> Otherwise, they will contain garbage, and cannot reliably be tested to see if the value was set.

This point comes up every few months, and what you say isn’t technically correct.

It doesn’t do anything useful to set a NSError* value returned via reference to nil before the method invocation. According to the particular pattern in use here, if the method succeeds, there’s no valid value returned for the NSError*. In this case, the value may have changed from the value before the call. The changed value is garbage, from the caller’s point of view.

It is *not safe* to test ‘error’ on a successful return, regardless of how you initialize it.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >JSONSerialization 'Garbage at end' error (From: Diederik Meijer | Ten Horses <email@hidden>)
 >Re: JSONSerialization 'Garbage at end' error (From: Jens Alfke <email@hidden>)
 >Re: JSONSerialization 'Garbage at end' error (From: Andy Lee <email@hidden>)
 >Re: JSONSerialization 'Garbage at end' error (From: Jonathan Hull <email@hidden>)

  • Prev by Date: Re: JSONSerialization 'Garbage at end' error
  • Next by Date: Re: JSONSerialization 'Garbage at end' error
  • Previous by thread: Re: JSONSerialization 'Garbage at end' error
  • Next by thread: Re: JSONSerialization 'Garbage at end' error
  • Index(es):
    • Date
    • Thread