Re: Keeping IB class instance and xCode instance the same
Re: Keeping IB class instance and xCode instance the same
- Subject: Re: Keeping IB class instance and xCode instance the same
- From: Graham Cox <email@hidden>
- Date: Mon, 20 Apr 2009 15:25:15 +1000
On 18/04/2009, at 9:03 AM, James Maxwell wrote:
I'm always anxious when I have to actually deal with IB... Sorry to
say it, but it's true. It just makes very little sense to me...
Anyway, I have a problem. I've got a class that's instantiated in
IB, but I need to load it's state from a file. This file defines the
class itself, so when I load the file, the instance changes, and my
UI stuff gets borked because everything is pointing at the instance
from IB, not the one loaded from the file... This probably isn't
making much sense.... The thing is that the IB stuff is recent.
Before I added any IB control, the class was instantiated in xCode,
so it was reeeeally easy to make sure the instance loaded from the
file *became* the instance I was working with in the app. In my IB-
challenged state, I know of no simple way to do this when working
with IB.
What I need to do, from what I can tell, is find some way to tell IB
that the instance it has should "sync" somehow with the instance
loaded from the file. Can I do that??? That is, can xCode tell IB to
assign its instance to the one from xCode?
This is a document based app, but the file I'm talking about is a
sort of "support" file for the app - it's not part of the document,
per se.
Any thoughts appreciated.
Hi James,
You need to go through the basic documentation on IB and in particular
"File's Owner".
Objects in IB are the actual objects, with the exception of File's
Owner, which is a proxy for an object in your app. That is pretty much
the sole means of 'syncing' stuff in IB to your app. While that could
be any object at all, typically it's the controller that manages the
interface that that particular nib contains.
If you have state info in a file, the controller could load this as
part of its setup. If the file contains an actual object, maybe the
controller could load and "own" this object. The term 'sync' usually
rings alarm bells because in general, any need to 'sync' two objects
or bits of data means your design is wrong.
I suspect this is sounding just as vague as anything else you've read.
Problem is, your question is a bit unfocused. That's why I suggest you
need to read up in the basic documentation about nib files and how
they work. Once you get a few key concepts straight there isn't much
mystery about IB and it should become obvious how to arrange things.
--Graham
_______________________________________________
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