We made a custom class to convert image views to JPEGs. I’ve used it before in another app with no problems. However, I am now getting a key value coding compliant error message.
Here’s the error message:
<NSWindow 0x3aa840> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imageViews.
We don’t have anything, in the code or in the class called imageViews so I don’t understand the error message. Is it speaking generically, like all image views? I didn’t write the class, I am beyond noob with this stuff. Can anyone help?
Here’s the class:
//
// testClass.h
// ImageExportTestAppleScript
//
// Created by Mike Galban on 10/25/07.
// Copyright 2007 MyCompanyName. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface testClass : NSObject {
IBOutlet NSView *view;
}
+(void)testMethod:(NSView *)view saveTo:(NSString *)myPath;
@end
=================================================
//
// testClass.m
// ImageExportTestAppleScript
//
// Created by Mike Galban on 10/25/07.
// Copyright 2007 MyCompanyName. All rights reserved.
//
#import “testClass.h”
@implementation testClass
+(void)testMethod:(NSView *)view saveTo:(NSString *)myPath
{
NSLog(@“export2 has been triggered, %@”,myPath);
[[NSGraphicsContext currentContext] setShouldAntialias:YES];
[view lockFocus];
NSRect bounds = [view bounds];
NSBitmapImageRep* rep;
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:bounds];
[view unlockFocus];
NSData* data;
data = [rep representationUsingType:NSJPEGFileType properties:nil];
[data writeToFile:myPath atomically:NO];
[rep release];
}
@end