[Biococoa-dev] unichar question

John Timmer jtimmer at bellatlantic.net
Fri Aug 20 22:45:56 EDT 2004


> You are using the following code the access a variable:
> 
> - (NSString *) name{
>      return [[name copy] autorelease];
> }
> 
> 
> Why not just use:
> 
> - (NSString *) name{
>      return name;
> }
> 
> Is there a particular reason why you use this format?

If you return a pointer to the actual name (as in the 2nd case), it's
possible to actually manipulate the contents of memory there in C.  By
returning a copy, you protect the actual instance variable.



> Oh, and what's the difference between symbolString and
> savableRepresentation?

In the nucleotide cases, none.  In the sequence classes, there will be. I
just thought it would be convenient to provide a single method signature
throughout the project so that people don't have to think about what to call
when they need something like that.


Cheers,

JT


_______________________________________________
This mind intentionally left blank





More information about the Biococoa-dev mailing list