Re: make connections without InterfaceBuilder
Re: make connections without InterfaceBuilder
- Subject: Re: make connections without InterfaceBuilder
- From: Ian Jackson <email@hidden>
- Date: Wed, 10 Feb 2010 01:44:26 +1300
On 10/02/2010, at 1:36 AM, Roland King wrote:
> No sorry this just won't work. Just because you give a button a given label in interface builder, that doesn't relate in any way to the instance variable in your code of the same name, that unfortunately is where the click-drag comes in, you connect the button at that point to the IBOutlet. When the NIB is unarchived all the objects are created, but only those things you have hooked up with Interface Builder are actually set to variables in your code.
>
> There is a way to do it the way you're trying to do it, but it's impossibly hard. You'd need to make the NIB, give each element on it a unique tag (not name, there's a tag field there too), then you have to load the NIB yourself from the bundle, which will give you all the top-level objects in it. Then you iterate them, look for your tags and set your instance variables to those objects. ie you do the last bit you cannot do in Interface Builder, in code.
>
I tried this NIB search idea before sending my previous email, and still didn't get my button to do anything, so I didn't bother to mention it. I found the button OK, set my outlet to be the one that I found. Then I stuck in some NSLogs to report the outlet's newly assigned selector, action, tag, title etc, which all gave the expected answer, but actually clicking the button did nothing. I probably did something stupid like assigned the tag to the wrong button mind you.
Ian. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden