Go Back   The macosxhints Forums > Working with OS X > OS X Developer



Reply
 
Thread Tools Rate Thread Display Modes
Old 01-18-2008, 06:32 AM   #1
ScottyDelicious
Prospect
 
Join Date: Jan 2005
Location: /Users/scottydelicious/
Posts: 18
Unknown Class `MySimpleClass` in nib file. Using NSObject instead.

I am having some trouble with pyObjC in Leopard/Xcode 3/Interface Builder 3.
I have created a new "Cocoa-Python Applicaion" (over a dozen times now), added a new python class (sub-class of NSObject) and tried coding my outlets and actions by hand, instantiating the class in IB3 and then choosing "Write Class File", I tried starting from IB3 with a generic object, giving it a name, some outlets and actions, then writing the file. In every case, The file shows up in Xcode with all the info It seems I should need (see below), but when I build and run, I get the error:


Unknown class `MySimpleClass' in nib file, using `NSObject' instead.

Could not connect the action ordain: to target of class NSObject

Application did finish launching.


The contents of MySimpleClass.py:
from Foundation import *
from AppKit import *
import objc
class MySimpleClass (NSObject):
mscTextArea = objc.IBOutlet()
mscWindow = objc.IBOutlet()

@objc.IBAction
def mscTest_(self, sender):
mscTextArea.setStringValue_(u"A string Value has been set.")

Please advise.

--
-sD-
Dr. Scotty Delicious, DFPA.
Doctor of Fine Pirate Arts.
ScottyDelicious is offline   Reply With Quote
Old 01-18-2008, 01:08 PM   #2
hayne
Moderator
 
Join Date: Jan 2002
Location: Montreal
Posts: 29,452
This kind of error message usually indicates that the class (MySimpleClass) was not linked into the executable - i.e. that you didn't add the implementation file for that class into your project.
__________________
hayne.net/macosx.html
hayne is online now   Reply With Quote
Old 01-18-2008, 02:16 PM   #3
ScottyDelicious
Prospect
 
Join Date: Jan 2005
Location: /Users/scottydelicious/
Posts: 18
Quote:
Originally Posted by hayne
This kind of error message usually indicates that the class (MySimpleClass) was not linked into the executable - i.e. that you didn't add the implementation file for that class into your project.

That is a good point.
Being a pyObjC python class, I don't have a separate header and implementation file, just the class file (which has the same name as the class, "MySimpleClass").

Opening the disclosure triangles for Targets > PyTest >Copy Bundle Resources shows both the PyTestAppDelegate.py file (auto-generated by Xcode) and my MySimpleClass.py file.

Under "Compile Sources" is the only Objective-C file needed for a pyObjC project, "main.m".

Going to the .app bundle and viewing package contents shows that MySimpleClass.py is being appropriately copied to the Resources folder in the bundle.

Needless to say this is quite confusing to me. I am posting here because over the years I have found many answers to my Cocoa programming questions at macosxhints.com via Google search results. A Google search for this error turned up a few pages of hits, but no solutions.

I figure when we get an answer to this, macosxhints.com's high page ranking should make it easier to find for anyone else having a similar issue.

-sD-
Dr. Scotty Delicious, DFPA.
ScottyDelicious is offline   Reply With Quote
Old 01-26-2008, 01:28 AM   #4
ScottyDelicious
Prospect
 
Join Date: Jan 2005
Location: /Users/scottydelicious/
Posts: 18
[!SOLVED!] Unknown Class `MySimpleClass` in nib file. Using NSObject instead.

Isn't it always true that our biggest problems stem from overlooking something terribly simple?

In all my excitement of exploring Interface Builder 3 (and its support for python and ruby classes!) I missed the obvious.

When I created my new Cocoa-Python project with Xcode 3, several files were created... including, obviously, main.m (for Cocoa runtime) and main.py.

After scouring the web for days I did what I should have done in the first place... Glance over the auto-generated source files to look for hints.

Right there in "main.py" is a comment that reads
Quote:
# import modules containing classes required to start application and load MainMenu.nib

I simply added...
Quote:
import MySimpleClass

then chose "Clean all targets" from the build menu, and clicked the "Build and Go" button.

It works perfectly now

I am willing to accept the fact that I look like a complete jack-a** right now, with the hope that someone else struggling with this will find this post on the first page of search results and get back on track with their project quickly.

-sD-
Dr. Scotty Delicious, DFPA.
ScottyDelicious is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting 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

Forum Jump


All times are GMT -5. The time now is 11:06 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Site design © Mac Publishing LLC; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of Mac Publishing LLC.
You Rated this Thread: