- (id)copyWithZone:(NSZone *)zone { PoolFacility *copy = [[[self class] allocWithZone:zone]init]; copy.name = [self.name copy]; copy.type = [self.type copy]; copy.phoneNumber = [self.phoneNumber copy]; //make sure I get proper copies of my dictionaries copy.address = [self.address mutableCopy]; copy.webAddress = [self.webAddress copy]; copy.prices = [self.prices mutableCopy]; copy.pools = [self.pools mutableCopy]; return copy; }
Can anyone see any memory leaks?
Here’s the property types:
NSString *name; NSString *type; NSMutableDictionary *address; NSString *phoneNumber; NSString *webAddress; NSMutableArray *prices; NSMutableArray *pools;
Here are the property declarations:
@property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *type; @property (nonatomic, copy) NSString *phoneNumber; @property (nonatomic, retain) NSMutableDictionary *address; @property (nonatomic, copy) NSString *webAddress; @property (nonatomic, retain) NSMutableArray *prices; @property (nonatomic, retain) NSMutableArray *pools;
The properties defined as copy and not retain will have an extra copy when set as below (your code)
it should be sufficient to only write them as