On Wed, Mar 17, 2010 at 2:16 PM, Kevin Brock <[email protected]> wrote:
> - (id)initWithText:(NSString*)field_contents
> {
> NSBundle* mybundle = [NSBundle
> bundleWithPath:@"/Library/Frameworks/MyFramework.framework"];
You shouldn't hardcode bundle paths like this. You could use
+[NSBundle bundleWithIdentifier:] (preferred) or +[NSBundle
bundleForClass:] instead.
> self = [self initWithNibName:@"MyEditText" bundle:mybundle];
> if(self)
> {
> [textField setStringValue:field_contents];
-initWithNibName:bundle: doesn't actually load the nib, so at this
point textField hasn't been hooked up to anything yet. If you set a
breakpoint on this line you'll find that textField == nil. You will
need to move this logic elsewhere.
The documentation for NSViewController (perhaps the release notes?)
makes oblique reference to NSWindowController's -windowDidLoad method,
which is designed for just this kind of scenario. NSViewController
doesn't have an analog for -windowDidLoad; instead you are expected to
override -loadView, call super's implementation, and then perform your
setup. That is the approach I would recommend.
You could theoretically do it in -awakeFromNib, but that won't work if
your view controller exists as an object in another nib, since it will
get -awakeFromNib twice.
Hope that helps,
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]