• 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: Stupid objective-c question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stupid objective-c question


  • Subject: Re: Stupid objective-c question
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 21 Sep 2016 22:33:05 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sS5zSm_QeE:SMTPCORP

On Sep 21, 2016, at 21:47 , Jeff Evans <email@hidden> wrote:
>
> Of course, so [[NSArray alloc]init] is actually useless; I hadn't thought of that. No one would ever declare an array that way.

Just continuing my nitpicking tour of this thread:

It isn’t useless. Sometimes you really want an empty array. For example, there are Cocoa APIs that have a parameter that’s an array of (say) options. In some cases, an API might accept nil as meaning “no options”, but in others it might throw an exception. It’s safer to pass [[NSArray alloc] init], or [NSArray array], or @[].

Another example where it might be needed is if you’re using “arrayByAddingObject:” or “arrayByAddingObjectsFromArray:” to construct an array, and you might want to start, conditionally, from an existing array or an empty array.

So it’s degenerate perhaps, but not exactly useless.

_______________________________________________

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: 
 >Stupid objective-c question (From: Gabriel Zachmann <email@hidden>)
 >Re: Stupid objective-c question (From: Graham Cox <email@hidden>)
 >Re: Stupid objective-c question (From: Quincey Morris <email@hidden>)
 >Re: Stupid objective-c question (From: Graham Cox <email@hidden>)
 >Re: Stupid objective-c question (From: Jens Alfke <email@hidden>)
 >Re: Stupid objective-c question (From: Jeff Evans <email@hidden>)
 >Re: Stupid objective-c question (From: Jens Alfke <email@hidden>)
 >Re: Stupid objective-c question (From: Jeff Evans <email@hidden>)

  • Prev by Date: Re: Stupid objective-c question
  • Next by Date: Re: Stupid objective-c question
  • Previous by thread: Re: Stupid objective-c question
  • Next by thread: Re: Stupid objective-c question
  • Index(es):
    • Date
    • Thread