Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSInternalInconsistencyException being thrown for unknown reason

NSInternalInconsistencyException being thrown for unknown reason
Thread Tools
apostacy
Junior Member
Join Date: Dec 2003
Location: New Jersey
Status: Offline
Reply With Quote
Oct 10, 2009, 07:42 PM
 
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
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Oct 10, 2009, 08:10 PM
 
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'."
     
apostacy  (op)
Junior Member
Join Date: Dec 2003
Location: New Jersey
Status: Offline
Reply With Quote
Oct 10, 2009, 11:41 PM
 
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
     
apostacy  (op)
Junior Member
Join Date: Dec 2003
Location: New Jersey
Status: Offline
Reply With Quote
Oct 11, 2009, 10:34 AM
 
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
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 01:14 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,