[Biococoa-dev] mass calculator bug

Koen van der Drift kvddrift at earthlink.net
Sat Aug 28 06:37:29 EDT 2004

On Aug 28, 2004, at 6:24 AM, Alexander Griekspoor wrote:

> Ha Koen,

Ha Alex :)

> This is because our custom object doesn't support the copying protocol 
> (see NSCopying in documentation). And now that we're busy anyway, 
> let's add the very similar NSCoding as well...  [DISCLAIMER: typed in 
> mail and not tested]

> So we start with the first interface line in the BCSequence header:
> @interface BCSequence : NSObject {
> should become:
> @interface BCSequence : NSObject <NSCopying, NSCoding> {

Hmm, I have never used such a construction before and have done similar 
things (passing an object to another class).

> In BCMassCalculator, InitWithSequence, change:
>> 	sequence = [seq copy];		<--------- error
> to sequence = [seq copyWithZone: [self zone]];  // I believe this is 
> more efficient memory wise

Even if I use an accessor:

[self setSequence: seq];

and then:

- (void)setSequence:(BCSequence *)s
	[s retain];
	[sequence release];
	sequence = s;

I get the same copywithZone error.  But maybe this is different because 
BCSequence passes a copy of itself?

Anyway, I agree that we should implemement a 'copy constructor' (C++ 
speak) if that solves the problem.

- Koen.

More information about the Biococoa-dev mailing list