Skip navigation.
 
mlFwd: NSString** in scanners
FROM : D.K. Johnston
DATE : Wed Jul 26 23:16:34 2006

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

Related mailsAuthorDate
mlFwd: NSString** in scanners D.K. Johnston Jul 26, 23:16
mlRe: NSString** in scanners Bill Bumgarner Jul 27, 00:25