Re: Cocoa n00b frustrations
Re: Cocoa n00b frustrations
- Subject: Re: Cocoa n00b frustrations
- From: Georg Tuparev <email@hidden>
- Date: Thu, 05 Jun 2008 22:20:46 +0200
On Jun 5, 2008, at 3:32 PM, Charles Jenkins wrote:
Hi! Despite the fact that you have heard from me before on this
list, I am still an newbie trying to struggle through writing my
first Cocoa app.
I have experienced a couple of frustrations that I would like to
share to see if anyone knows tools or practices that will help avoid
them in the future.
NAUGHTY NIBS
I had a Nib file that went bad. Suddenly, my outlets doubled up: IB
indicated that a class had two outlets named 'textField1' and
'textField2'.
When it came time to make connections, I had no way to tell the real
ones from the ghost ones, so I changed the outlets' names in my code
files and resynchronized. From that point, IB insisted that both the
old and new connections existed. Worried that this might be the
source of another problem I was having, I did everything I could
think of to get rid of the non-existent outlets: I deleted the .h/.m
and recreated them; I deleted and recreated the NSObject instance in
IB; I deleted both the .h/.m pair AND the NSObject instance and
recreated it all using a different class name (MyController instead
of WindowController); and finally closed down IB and Xcode and
edited the XIB file with TextWrangler to delete the non-existent
outlet names.
Nothing worked--the new NSObject instance always magically retained
the memory of textField1 and textField2--until I gave up on the Nib
file by renaming my project directory and creating a new project so
that I would start with a fresh Nib file. Then I moved my .h/.m
files over and connected them with no problem to the new Nib.
Is there any kind of Nib repair utility that will clean up a Nib
file to remove outlets, actions, and classes that do not connect up
to anything in code? Having such an important file just suddenly "go
bad" and have to be recreated from scratch is a real bummer.
I never had that problem, but if I recall correctly, someone
complained about this during the Leopard-preview times. Are you sure
you have no leftovers from the beta?
DELEGATE DISILLUSIONMENT
You create an object (.h, .m, and object instance in IB) that a
control (like a table view) will use as a delegate. Using the
documentation, you cut and paste the delegate's signature to
eliminate any chance that a typo will prevent it from working. In
IB, you make sure that the control's 'delegate:' is connected to the
object.
At runtime, the delegate never gets called.
If checking and rechecking the connection and the method's
declaration and implementation doesn't help, how do you solve the
problem?
Objective-C's delegation paradigm is like magic when it works, but
mysterious and frustrating when there is a problem. Besides a
malformed method signature and a missing IB connection, what else
could be wrong?
I use delegation extensively for (oh) 17 years. Never ever had this
problem. Without looking at your project cannot say what is the cause.
Do you by any chance override setDelegate: or setting the delegate in
another setter? Are you sure your object is not nil?
cheers
FINALLY
Anyone know of a Cocoa user group in the Knoxville, Tennessee area?
Thanks!
Georg Tuparev
Tuparev Technologies
Klipper 13
1186 VR Amstelveen
The Netherlands
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden