I have problem with this code, it's working on debug environment. On the instruments I'm seeing memory leak problem on this function, instruments is giving warning that
Category Event Type Timestamp Address Size Responsible Library Responsible Caller 27 SocialNetwork Malloc 00:19.951 0x3d64d20 80 Foundation -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
- (NSMutableArray *)GetDataInstanceToUserDefaults{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSData *storedObject = [userDefaults objectForKey:@"MyDataKey"];
NSMutableArray *data;
if(storedObject != nil)
{
NSArray *savedArray = [NSKeyedUnarchiver unarchiveObjectWithData:storedObject];
if(savedArray != nil)
data = [[NSMutableArray alloc] initWithArray:savedArray];
else
data = [[NSMutableArray alloc] init];
}else{
data = [[NSMutableArray alloc] init];
}
return data;
}
I didn't understand where is the my problem ?
Thank you for your support
Edit : By the way I should give more detail about this problem,this function (as you can see) is storing my object. My object is custom class and storing in the NSMutableArray.
I already added these methods inside of the my custom class
-(void)encodeWithCoder:(NSCoder *)coder{
-(id)copyWithZone:(NSZone*)zone {
-(id)initWithCoder:(NSCoder *)coder{