XCode/Interface Builder connections bug

Moderator
Posts: 1,140
Joined: 2005.07
Post: #1
I just found a bug in XCode and Interface builder. (It was the reason for my problem in the thread I posted yesterday) It goes as follows: if you have an IBOutlet object of some name, and a set method using the same name, the IBOutlet object will become nil. I created a test project which you can download here. In it, I have an NSTextField test object (which I connect to testString), and I also have a setTestString method. I test to see if testString is nil, and output (in another NSTextField) whether it's nil or not. If you run it as-is, with the set method in, it's nil. If you comment out the set method, it's no longer nil. It's a good idea to keep this in mind if this happens to you, since I spent basically an entire day before I figured out something with the name was wrong. (I also experienced it a few times today, which then led me to the exact cause)

And yes, I already sent a bug report to Apple. Smile
Quote this message in a reply
Member
Posts: 114
Joined: 2005.03
Post: #2
Are you sure that that's a bug? Official Apple documentation states that they will try to set the value for an outlet first with a set method, then directly. So if the outlet is called testString and you have a method called setTestString, IB will try to connect that outlet not by setting testString directly, but by calling setTestString.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #3
I was wondering if that was the case, but I personally think that it should always directly set it. I don't know if other people rely on the set methods for connections, but I personally don't see any need for it. It's merely caused me trouble so far.
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #4
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #5
I use key codes. But not for IBOutlets that are connected through Interface Builder. Rasp

Edit: and IBOutlet connections were around long before key-codes were introduced in Panther, so it's not like they must rely on the key codes.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Interface Builder Tutorials Talyn 1 2,481 Sep 29, 2008 08:56 PM
Last Post: Terrydil
  Interface Builder bindings _Bison_ 4 3,383 Jan 11, 2008 01:11 PM
Last Post: SethWillits
  Interface Builder won't launch Jake 2 2,813 Sep 22, 2006 03:42 PM
Last Post: Jake
  Information on how to structure networking for gaming - Not how to code connections lfrog 5 6,859 Nov 28, 2005 05:29 PM
Last Post: Skorche
  Dumb Xcode interface question... WhatMeWorry 1 2,944 Oct 17, 2005 02:24 PM
Last Post: Taxxodium