|
|
NSInternalInconsistencyException being thrown for unknown reason
|
|
|
|
Junior Member
Join Date: Dec 2003
Location: New Jersey
Status:
Offline
|
|
I'm trying to get an example from Hillegass' Cocoa Programming for Mac OS X book to run, and I keep getting an I'm NSInternalInconsistencyException , though I'm not sure why.
The purpose of the app is to show how Key-Value Coding can be binded (bound?) to an application.
Here's my code:
Code:
//
// AppController.h
//
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject {
double fido;
}
- (id)init;
- (double)fido;
- (void)setFido:(double)x;
@end
//
// AppController.m
//
#import "AppController.h"
@implementation AppController
- (id)init
{
[super init];
[self setValue:[NSNumber numberWithDouble:5]
forKey:@"fido"];
NSNumber* number = [self valueForKey:@"fido"];
NSLog(@"fido: %@",number);
return self;
}
- (double)fido
{
NSLog(@"-fido is returning %d", fido);
return fido;
}
- (void)setFido:(double)x
{
NSLog(@"-setFido: is called with %d", x);
fido = x;
}
@end
In Interface Builder, I'm simply dragging a vertical slider to the default .nib window, and checking "Continuous" "Bind to: AppController" (<- the name of OOP object I've created).
Fido was initially an int, but I changed it to a double because I was getting an exception:
Code:
2009-10-10 19:21:43.126 KVCFun[5084:10b] An uncaught exception was raised
2009-10-10 19:21:43.127 KVCFun[5084:10b] Cannot create double from object <AppController: 0x130700> of class AppController
2009-10-10 19:21:43.128 KVCFun[5084:10b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot create double from object
The problem is, whenever I run it, I get the follow exception thrown:
Code:
2009-10-10 19:22:38.403 KVCFun[5113:10b] Cannot create double from object <AppController: 0x130700> of class AppController
2009-10-10 19:22:38.404 KVCFun[5113:10b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot create double from object <AppController: 0x130700> of class AppController'
Any suggestions as to what could be wrong?
|
MacBook 2.4 GHz
Mac OS X 10.5.8
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
I think you want to bind to a particular property of the AppController rather than the AppController itself.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Junior Member
Join Date: Dec 2003
Location: New Jersey
Status:
Offline
|
|
Thanks Chuckit, and you sent me in the right direction. I needed to put the Object *and* the field name in the Inspector with focus on the slider. Thanks...
|
MacBook 2.4 GHz
Mac OS X 10.5.8
|
|
|
|
|
|
|
|
Junior Member
Join Date: Dec 2003
Location: New Jersey
Status:
Offline
|
|
Anyone know why I'm binding to "App Controller" or what "App Controller" is? The class I created in the above example happens to be called AppController, but it's obviously not referring to that (there's no space in my class name). It sounds like a reference to a Controller of the MVC model, but how does Interface Builder know what class I want to use as the Controller? (Didn't see any explanation anywhere online.)
(
Last edited by apostacy; Oct 11, 2009 at 11:53 AM.
)
|
MacBook 2.4 GHz
Mac OS X 10.5.8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|