我有一个 IkImageBrowserView 实例,用于在我的应用程序中显示文件中的图片。一切正常,但用另一个视图替换它。
2012-05-23 12:37:29.690 test[3595:903] --ImageKit Error: IKCacheDatabase::entryAtIndex - bad index
2012-05-23 12:37:29.691 test[3595:903] --ImageKit Error: entry #-1 doesn't exist
2012-05-23 12:37:29.691 test[3595:903] --ImageKit Error: IKCacheDatabase::entryAtIndex - bad index
2012-05-23 12:37:29.692 test[3595:903] --ImageKit Error: entry #-1 doesn't exist
2012-05-23 12:37:29.693 test[3595:903] --ImageKit Error: IKCacheDatabase::entryAtIndex - bad index
2012-05-23 12:37:29.693 test[3595:903] --ImageKit Error: IKCacheDatabase::entryAtIndex - bad index
2012-05-23 12:37:29.693 test[3595:903] --ImageKit Error: IKCacheDatabase::entryAtIndex - bad index
2012-05-23 12:37:29.694 test[3595:903] --ImageKit Error: entry #-1 doesn't exist
2012-05-23 12:37:29.695 test[3595:903] --ImageKit Error: IKCacheDatabase::entryAtIndex - bad index
2012-05-23 12:37:29.695 test[3595:903] --ImageKit Error: entry #-1 doesn't exist
2012-05-23 12:37:29.696 test[3595:903] --ImageKit Error: ram manager::bind can't find cache node with uid: -1 size: 44
我做了一些实验,发现这个消息不会导致应用程序崩溃。而不是每次我用其他视图替换浏览器视图时都会发生。有时我关闭视图,消息也会出现。下面的代码是 browserView 项。根据错误消息,它可能是由图像缓存引起的..但我找不到问题所在
@interface ASFileBrowserViewItem : NSObject
@property(retain) NSImage* itemImage;
@property(retain) NSString* imagePath;
- (id)initWithPath:(NSString*)path;
@end
#import "ASFileBrowserViewItem.h"
#import <Quartz/Quartz.h>
@implementation ASFileBrowserViewItem
@synthesize itemImage = _itemImage;
@synthesize imagePath = _imagePath;
- (id)initWithPath:(NSString*)path
{
self = [super init];
if (self) {
self.imagePath = path;
_itemImage = [[NSImage alloc] initWithContentsOfFile:path];
}
return self;
}
- (void)dealloc
{
[_imagePath release];
[_itemImage release];
[super dealloc];
}
#pragma mark require from IKImageBrowserView Protocol
- (NSString *) imageUID
{
return _imagePath;
}
- (NSString *) imageRepresentationType
{
return IKImageBrowserNSImageRepresentationType;
}
- (id) imageRepresentation
{
return _itemImage;
}
- (NSString *) imageTitle
{
return [_imagePath lastPathComponent];
}
@end