Crashing memory leak
I keep on getting this kind of crash. When I use the code provided in the sample it works fine but when I try to make my own, it crashes all the time. The crash log is;
[GSFont release]: message sent to deallocated instance
My UITableViewCell subclass are very simple. I dont know what is wrong here.
#import <UIKit/UIKit.h>
#import "RTLabel.h"
#define FROM_IMAGE_VIEW CGRectMake(8,8,32,32)
#define FROM_LABEL CGRectMake(48, 8, 320 - 48 - 16 - 8 - 8, 32)
#define SOURCE_ICON CGRectMake(320 - 8 - 16, 14, 16,16)
#define CUTLINE_IMAGE_VIEW CGRectMake(0, 8+32+8, 320, 1)
#define MESSAGE_LABEL CGRectMake(8,8+32+8+1+8, 320 - 8 - 8, 32)
#define TARGET_IMAGE_VIEW CGRectMake(8,8+32+8+1 + 8 + 32 + 8, 320 - 8 - 8 - 100, 90)
#define CAPTION_LABEL CGRectMake(8,8+32+8+1+ 8 + 32 + 8 + 90 + 8, 320 - 8 - 8, 32)
@interface Cell : UITableViewCell
@property(nonatomic, strong) UIImageView *fromImageView;
@property(nonatomic, strong) RTLabel *fromLabel;
@property(nonatomic, strong) RTLabel *messageLabel;
@property(nonatomic, strong) UIImageView *sourceIcon;
@property(nonatomic, strong) UIImageView *targetImageView;
@property(nonatomic, strong) RTLabel *captionLabel;
@property(nonatomic, strong) UIImageView *cutlineImageView;
@end
#import "Cell.h"
@implementation Cell
@synthesize fromImageView;
@synthesize fromLabel;
@synthesize messageLabel;
@synthesize sourceIcon;
@synthesize captionLabel;
@synthesize targetImageView;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
self.fromLabel = [self from];
self.fromLabel.font = [UIFont boldSystemFontOfSize:13];
self.fromLabel.backgroundColor = [UIColor clearColor];
self.fromImageView = [[UIImageView alloc] initWithFrame:FROM_IMAGE_VIEW];
self.messageLabel = [self message];
self.messageLabel.backgroundColor = [UIColor clearColor];
self.messageLabel.font = [UIFont boldSystemFontOfSize:13];
[self.messageLabel setParagraphReplacement:@""];
self.sourceIcon = [[UIImageView alloc] initWithFrame:SOURCE_ICON];
self.captionLabel = [self caption];
self.captionLabel.backgroundColor = [UIColor clearColor];
self.captionLabel.font = [UIFont boldSystemFontOfSize:13];
[self.captionLabel setParagraphReplacement:@""];
self.targetImageView = [[UIImageView alloc] initWithFrame:TARGET_IMAGE_VIEW];
[self.contentView addSubview:self.fromLabel];
[self.contentView addSubview:self.fromImageView];
[self.contentView addSubview:self.messageLabel];
[self.contentView addSubview:self.sourceIcon];
[self.contentView addSubview:self.captionLabel];
[self.contentView addSubview:self.targetImageView];
[self.contentView setBackgroundColor:[UIColor lightGrayColor]];
}
return self;
}
- (RTLabel*)from
{
RTLabel *label = [[RTLabel alloc] initWithFrame:FROM_LABEL];
[label setParagraphReplacement:@""];
return label;
}
- (RTLabel*)message
{
RTLabel *label = [[RTLabel alloc] initWithFrame:MESSAGE_LABEL];
[label setParagraphReplacement:@""];
return label;
}
- (RTLabel*)caption
{
RTLabel *label = [[RTLabel alloc] initWithFrame:CAPTION_LABEL];
[label setParagraphReplacement:@""];
return label;
}
@end
r u using ARC?
On 22 Nov, 2012, at 7:49 PM, Sandeep [email protected] wrote:
I keep on getting this kind of crash. When I use the code provided in the sample it works fine but when I try to make my own, it crashes all the time. The crash log is;
[GSFont release]: message sent to deallocated instance
My UITableViewCell subclass are very simple. I dont know what is wrong here.
#import <UIKit/UIKit.h> #import "RTLabel.h" #define FROM_IMAGE_VIEW CGRectMake(8,8,32,32) #define FROM_LABEL CGRectMake(48, 8, 320 - 48 - 16 - 8 - 8, 32) #define SOURCE_ICON CGRectMake(320 - 8 - 16, 14, 16,16) #define CUTLINE_IMAGE_VIEW CGRectMake(0, 8+32+8, 320, 1) #define MESSAGE_LABEL CGRectMake(8,8+32+8+1+8, 320 - 8 - 8, 32) #define TARGET_IMAGE_VIEW CGRectMake(8,8+32+8+1 + 8 + 32 + 8, 320 - 8 - 8 - 100, 90) #define CAPTION_LABEL CGRectMake(8,8+32+8+1+ 8 + 32 + 8 + 90 + 8, 320 - 8 - 8, 32) @interface Cell : UITableViewCell @property(nonatomic, strong) UIImageView *fromImageView; @property(nonatomic, strong) RTLabel *fromLabel; @property(nonatomic, strong) RTLabel *messageLabel; @property(nonatomic, strong) UIImageView *sourceIcon; @property(nonatomic, strong) UIImageView *targetImageView; @property(nonatomic, strong) RTLabel *captionLabel; @property(nonatomic, strong) UIImageView *cutlineImageView; @end #import "Cell.h"
@implementation Cell @synthesize fromImageView; @synthesize fromLabel; @synthesize messageLabel; @synthesize sourceIcon; @synthesize captionLabel; @synthesize targetImageView;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){ self.fromLabel = [self from]; self.fromLabel.font = [UIFont boldSystemFontOfSize:13]; self.fromLabel.backgroundColor = [UIColor clearColor]; self.fromImageView = [[UIImageView alloc] initWithFrame:FROM_IMAGE_VIEW]; self.messageLabel = [self message]; self.messageLabel.backgroundColor = [UIColor clearColor]; self.messageLabel.font = [UIFont boldSystemFontOfSize:13]; [self.messageLabel setParagraphReplacement:@""]; self.sourceIcon = [[UIImageView alloc] initWithFrame:SOURCE_ICON]; self.captionLabel = [self caption]; self.captionLabel.backgroundColor = [UIColor clearColor]; self.captionLabel.font = [UIFont boldSystemFontOfSize:13]; [self.captionLabel setParagraphReplacement:@""]; self.targetImageView = [[UIImageView alloc] initWithFrame:TARGET_IMAGE_VIEW]; [self.contentView addSubview:self.fromLabel]; [self.contentView addSubview:self.fromImageView]; [self.contentView addSubview:self.messageLabel]; [self.contentView addSubview:self.sourceIcon]; [self.contentView addSubview:self.captionLabel]; [self.contentView addSubview:self.targetImageView]; [self.contentView setBackgroundColor:[UIColor lightGrayColor]]; } return self; }
- (RTLabel*)from { RTLabel *label = [[RTLabel alloc] initWithFrame:FROM_LABEL]; [label setParagraphReplacement:@""]; return label; }
- (RTLabel*)message { RTLabel *label = [[RTLabel alloc] initWithFrame:MESSAGE_LABEL]; [label setParagraphReplacement:@""]; return label; }
- (RTLabel*)caption { RTLabel *label = [[RTLabel alloc] initWithFrame:CAPTION_LABEL]; [label setParagraphReplacement:@""]; return label; } @end — Reply to this email directly or view it on GitHub.
Yes