• 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
Fwd: NSString** in scanners
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: NSString** in scanners


  • Subject: Fwd: NSString** in scanners
  • From: "D.K. Johnston" <email@hidden>
  • Date: Wed, 26 Jul 2006 14:16:34 -0700

On 26 Jul, 2006, at 10:38, j o a r wrote:

Why do scanner methods such as:
scanCharactersFromSet:intoString:
require an NSString** as their second parameter, rather than simply an NSString*?

Because the method argument is used to _return_ a pointer to a NSString object to the caller of the method. This in contrast to how method arguments are used in the overwhelming majority of cases in Cocoa; where they're used by the caller to provide the method with an argument needed for the method to perform it's work.

I understand that if I want the scanned characters to be placed in:

	NSString *string;

I need to send "&string" to the method, which then presumably does something like this:

	*string = [internalWorkingString copy];

But if the method got "string" instead of "&string", couldn't it just do this:

	string = [internalWorkingString copy];

with the same result?

dkj


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: NSString** in scanners
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: How to make KVO setup persistent?
  • Next by Date: Dynamic NSPopUpButton in NSToolbar
  • Previous by thread: Re: NSString** in scanners
  • Next by thread: Re: NSString** in scanners
  • Index(es):
    • Date
    • Thread