Reputation: 27
While compiling I received 2 errors..
Undefined symbols for architecture i386:
"_IKImageBrowserNSURLRepresentationType", referenced from:
-[ATDesktopEntity imageRepresentationType] in ATDesktopEntity.o
".objc_class_name_CABasicAnimation", referenced from: pointer-to-literal-objc-class-name in ATColorView.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've included to 2 implementation files where I feel the problem is occurring...
#import "ATDesktopEntity.h"
#import <Quartz/Quartz.h>
#define THUMBNAIL_HIEGHT 180.0
#define DEMO_MODE 0
@implementation ATDesktopEntity
+ (ATDesktopEntity *)entityForURL:(NSURL *)url {
NSString *typeIdentifier;
if ([url getResourceValue:&typeIdentifier forKey:NSURLTypeIdentifierKey
error:NULL]) {
NSArray *imageUTIs = [NSImage imageTypes];
if ([imageUTIs containsObject:typeIdentifier]) {
return [[[ATDesktopImageEntity alloc] initWithFileURL:url] autorelease];
}else if ([typeIdentifier isEqualToString:(NSString *)kUTTypeFolder]){
return [[[ATDesktopFolderEntity alloc] initWithFileURL:url] autorelease];
}
}
return nil;
}
@synthesize fileURL = _fileURL;
@dynamic title;
- (id)initWithFileURL:(NSURL *)fileURL
{
self = [super init];
_fileURL = [fileURL retain];
return self;
}
- (id)copyWithZone:(NSZone *)zone
{
id result = [[[self class] alloc] initWithFileURL:self.fileURL];
return result;
}
- (NSString *)description
{
return [NSString stringWithFormat:@"%@ : %@", [super description], self.title];
}
- (void)dealloc
{
[_fileURL release];
[super dealloc];
}
- (NSString *)title
{
NSString *result;
if ([self.fileURL getResourceValue:&result forKey:NSURLLocalizedNameKey
error:NULL]) {
return result;
}
return nil;
}
#pragma mark -
#pragma mark NSPasteboardWriting support
- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard
{
return [self.fileURL writableTypesForPasteboard:pasteboard];
}
- (id)pasteboardPropertyListForType:(NSString *)type
{
return [self.fileURL pasteboardPropertyListForType:type];
}
- (NSPasteboardWritingOptions)writingOptionsForType:(NSString *)type pasteboard:
(NSPasteboard *)pasteboard
{
if ([self.fileURL respondsToSelector:@selector(writingOptionsForType:pasteboard:)])
{
return [self.fileURL writingOptionsForType:type pasteboard:pasteboard];
}else{
return 0;
}
}
#pragma mark -
#pragma mark NSPasteboardReading support
+ (NSArray *)readableTypesForPasteboard:(NSPasteboard *)pasteboard
{
return [NSArray arrayWithObjects:(id)kUTTypeFolder, (id)kUTTypeFileURL, nil];
}
+ (NSPasteboardReadingOptions)readingOptionsForType:(NSString *)type pasteboard:
(NSPasteboard *)pasteboard
{
return NSPasteboardReadingAsString;
}
- (id)initWithPasteboardPropertyList:(id)propertyList ofType:(NSString *)type
{
[self release];
self = nil;
NSURL *url = [[[NSURL alloc] initWithPasteboardPropertyList:propertyList
ofType:type] autorelease];
NSString *urlUTI;
if ([url getResourceValue:&urlUTI forKey:NSURLTypeIdentifierKey error:NULL
]) {
if ([[NSImage imageTypes] containsObject:urlUTI]) {
self = [[ATDesktopImageEntity alloc] initWithFileURL:url];
}else if ([urlUTI isEqualToString:(id)kUTTypeFolder]) {
self = [[ATDesktopFolderEntity alloc] initWithFileURL:url];
}
}
return self;
}
#pragma mark -
- (NSString *)imageUID
{
return [NSString stringWithFormat:@"%p", self];
}
- (NSString *)imageRepresentationType
{
return IKImageBrowserNSURLRepresentationType;
}
- (id)imageRepresentation
{
return self.fileURL;
}
- (NSUInteger)imageVersion
{
return 0;
}
- (NSString *)imageTitle
{
return self.title;
}
- (NSString *)imageSubtitle
{
return nil;
}
- (BOOL)isSelectable
{
return YES;
}
@end
@interface ATDesktopImageEntity()
@property (readwrite, retain) NSImage *thumbnailImage;
@property (readwrite) BOOL imageLoading;
@end
static NSOperationQueue *ATSharedOperationQueue()
{
static NSOperationQueue *_ATSharedOperationQueue = nil;
if (_ATSharedOperationQueue == nil) {
_ATSharedOperationQueue = [[NSOperationQueue alloc] init];
[_ATSharedOperationQueue setMaxConcurrentOperationCount:2];
}
return _ATSharedOperationQueue;
}
@implementation ATDesktopImageEntity
- (id)initWithFileURL:(NSURL *)fileURL
{
self = [super initWithFileURL:fileURL];
static NSInteger lastColorIndex = 0;
NSColorList *colorList = [NSColorList colorListNamed:@"Crayons"];
NSArray *keys = [colorList allKeys];
if (lastColorIndex >= keys.count) {
lastColorIndex = 0;
}
_fillColorName = [[keys objectAtIndex:lastColorIndex++] retain];
_fillColor = [[colorList colorWithKey:_fillColorName] retain];
self.title = [super title];
return self;
}
- (void)dealloc
{
[_thumbnailImage release];
[_image release];
[_fillColor release];
[_fillColorName release];
[_title release];
[super dealloc];
}
@synthesize fillColor = _fillColor;
@synthesize fillColorName = _fillColorName;
@synthesize imageLoading = _imageLoading;
@synthesize image = _image;
@synthesize thumbnailImage = _thumbnailImage;
@synthesize title = _title;
static NSImage *ATThumbnailImageFromImage(NSImage *image)
{
NSSize imageSize = [image size];
CGFloat imageAspectRatio = imageSize.width / imageSize.height;
NSSize thumbnailSize = NSMakeSize(THUMBNAIL_HIEGHT * imageAspectRatio,
THUMBNAIL_HIEGHT);
NSImage *thumbnailImage = [[NSImage alloc] initWithSize:thumbnailSize];
[thumbnailImage lockFocus];
[image drawInRect:NSMakeRect(0, 0, thumbnailSize.width, thumbnailSize.
height) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
[thumbnailImage unlockFocus];
#if DEMO_MODE
usleep(250000);
#endif
return [thumbnailImage autorelease];
}
- (NSImage *)thumbnailImage
{
if (self.image != nil && _thumbnailImage == nil) {
_thumbnailImage = [ ATThumbnailImageFromImage(self.image) retain];
}else if (self.image == nil && !self.imageLoading) {
[self loadImage];
}
return _thumbnailImage;
}
- (void)loadImage
{
@synchronized (self) {
if (self.image == nil && !self.imageLoading) {
self.imageLoading = YES;
[ATSharedOperationQueue() addOperationWithBlock:^(void) {
NSImage *image = [[NSImage alloc] initWithContentsOfURL:self.fileURL];
if (image != nil) {
NSImage *thumbnailImage = ATThumbnailImageFromImage(image);
@synchronized (self) {
self.imageLoading = NO;
self.image = image;
self.thumbnailImage = thumbnailImage;
}
[image release];
}else{
@synchronized (self) {
self.image = [NSImage imageNamed:NSImageNameTrashFull];
}
}
}];
}
}
}
@end;
@implementation ATDesktopFolderEntity
- (void)dealloc
{
[_children release];
[super dealloc];
}
@dynamic children;
- (NSMutableArray *)children
{
NSMutableArray *result = nil;
@synchronized (self) {
if (_children == nil && self.fileURL != nil) {
NSError *error = nil;
NSArray *urls = [[NSFileManager defaultManager]
contentsOfDirectoryAtURL:self.fileURL
includingPropertiesForKeys:[NSArray
arrayWithObjects:NSURLLocalizedNameKey, nil]
options:
NSDirectoryEnumerationSkipsHiddenFiles |
NSDirectoryEnumerationSkipsSubdirectoryDescendants error:&error];
NSMutableArray *newChildren = [[NSMutableArray alloc] initWithCapacity:urls.count];
for (NSURL *url in urls) {
NSString *typeIndentifier;
if ([url getResourceValue:&typeIndentifier forKey:
NSURLTypeIdentifierKey error:NULL]) {
ATDesktopEntity *entity = [ATDesktopEntity entityForURL:url];
if (entity) {
newChildren addObject:entity];
}
}
}
_children = newChildren;
}
result = [[_children retain] autorelease];
}
return result;
}
- (void)setChildren:(NSMutableArray *)value
{
@synchronized (self) {
if (_children != value) {
[_children release];
_children = [value retain];
}
}
}
@end
NSString *const ATEntityPropertyNamedFillColor = @"fillColor";
NSString *const ATEntityPropertyNamedFillColorName = @"fillColorName";
NSString *const ATEntityPropertyNamedImage = @"image";
NSString *const ATEntityPropertyNamedThumbnailImage = @"thumbnailImage";
Second file..
#import "ATColorView.h"
#import <Quartz/Quartz.h>
@implementation ATColorView
+ (id)defaultAnimationForKey:(NSString *)key{
if ([key isEqualToString:@"backgroundColor"]) {
return [CABasicAnimation animation];
}
return [super defaultAnimationForKey:key];
}
- (void)dealloc
{
self.backgroundColor = nil;
[super dealloc];
}
@synthesize backgroundColor;
@synthesize drawBorder;
- (CGColorRef)createBackgroundColorRef
{
CGFloat components[backgroundColor.numberOfComponents];
[backgroundColor getComponents:components];
return CGColorCreate([[backgroundColor colorSpace] CGColorSpace],components);
}
- (void)setBackgroundColor:(NSColor *)value
{
if (backgroundColor != value) {
[backgroundColor release];
backgroundColor = [value retain];
if (self.layer == nil) {
CGColorRef backgroundColorRef = [self createBackgroundColorRef];
self.layer.backgroundColor = backgroundColorRef;
CGColorRelease(backgroundColorRef);
}
[self setNeedsDisplay:YES];
}
}
- (void)drawRect:(NSRect)r
{
NSColor *color = [self backgroundColor];
if (color) {
[color set];
NSRectFill(r);
}
if (self.drawBorder) {
[[NSColor lightGrayColor] set];
NSFrameRectWithWidth(self.bounds, 1.0);
}
if (self.window.firstResponder == self) {
NSSetFocusRingStyle(NSFocusRingOnly);
NSRectFill(self.bounds);
}
}
- (void)mouseUp:(NSEvent *)theEvent
{
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
if (NSPointInRect(point, self.bounds) && self.action) {
[NSApp sendAction:self.action to:self.target];
}
}
+ (Class)cellClass {
return [NSActionCell class];
}
@end
Upvotes: 1
Views: 2677
Reputation: 17478
Change the line #import <Quartz/Quartz.h>
to #import <QuartzCore/QuartzCore.h>
Also make sure you have linked those libraries and Frameworks to your project.
For more info, please check this post
Upvotes: 1