hi ,
i am display the image in IkImageBrowserView using IKImageBrowserNSDataRepresentationType, but here is memory leak please anybody can help me to find out this and resolve this.
please help me.
thanks.
i am display the image in IkImageBrowserView using IKImageBrowserNSDataRepresentationType, but here is memory leak please anybody can help me to find out this and resolve this.
Code:
@interface MyImageObject : NSObject
{
NSMutableData * imageData;
NSString * image_Name;
}
@end
@implementation MyImageObject
- (id)initWithImage_data:(NSMutableData *)animageData image_Name:(NSString *)anImageName
{
if (self = [super init])
{
imageData = [animageData copy];
image_Name = [anImageName copy];
}
return self;
}
- (void) dealloc
{
[imageData release];
[image_Name release];
[super dealloc];
}
/* let the image browser knows we use a path representation */
- (NSString *) imageRepresentationType
{
return IKImageBrowserNSDataRepresentationType;
}
/* give our representation to the image browser */
- (id) imageRepresentation
{
return imageData;
}
/* use the absolute filepath as identifier */
- (NSString *) imageUID
{
return image_Name;
}
- (id) imageTitle
{
return image_Name;
}
@end
and use this method from main class to pass NSMutabledata for image file
- (void) addImageWithData:(NSMutableData *)animageData imageName:(NSString*)anImageName
{
if([animageData length]==0)
{
return;
}
NSString * noprevfile=@"";
MyImageObject *item ;
NSAutoreleasePool *rel_pool = [NSAutoreleasePool new];
NSImage *thisImage = [[NSImage alloc]initWithData:animageData];
if(![thisImage isValid])
{
noprevfile = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"NoPreview.png"];
if([fileManager fileExistsAtPath:noprevfile])
{
animageData=[[NSData alloc] initWithContentsOfFile:noprevfile];
}
}
[thisImage release];
item = [[MyImageObject alloc] initWithImage_data:animageData image_Name:anImageName] ;
[images addObject:item];
[animageData setLength:0];
[item release];
[rel_pool release];
[imageBrowser reloadData];
[imageBrowser scrollIndexToVisible:[images count] - 1];
}
please help me.
thanks.