|
|||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
#1 |
|
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. |
|
|
|
|
|
#2 |
|
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 |
|
|
|
|
|
#3 | |||||||||||||||||||||||
|
Prospect
Join Date: Jan 2005
Location: /Users/scottydelicious/
Posts: 18
|
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. |
|||||||||||||||||||||||
|
|
|
|
|
#4 | ||||||||||||||||||||||||||||||||||||||
|
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
I simply added...
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. |
||||||||||||||||||||||||||||||||||||||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|