I try to create a copying method confering to the protocol NSCopying.
I have the following class:
@interface Gene : NSObject <NSCopying>
{
int firstAllele;
int secondAllele;
}
with the method:
-(id) copyWithZone:(NSZone*) zone
{
id clonedGene = [[[self class] allocWithZone:zone] initWithAllele1:first andAllele2:second];
return clonedGene;
}
if I call the method the following way:
Gene* gene1 = [[Gene alloc]initWithAllele1:4 andAllele2:2];
Gene* gene2 = [gene1 copy];
it crashes while calling the copy method of gene1.
do I have to call the method differently?
like [gene1 copyWithZone:(NSZone *)]
but what object will I have to pass? do I have to create an NSZone object? or is there a default one I can pass as argument?
Thank you for any help