Fwd: NSString** in scanners
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