• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa bootstrap
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa bootstrap


  • Subject: Re: Cocoa bootstrap
  • From: Sherm Pendley <email@hidden>
  • Date: Thu, 10 May 2007 19:43:46 -0400

Also, if you're going to split the +alloc and -init (or - initWithWindowNibName:) messages into two lines, don't ignore the return value of -init. Initializers aren't required to return self, so the return value from the initializer message isn't guaranteed to be the same object you sent it to.

For example:

	XTensionController *cntl = [XTensionController alloc];
	cntl = [cntl initWithWindowNibName:@"Converter"];

sherm--

On May 10, 2007, at 7:29 PM, Andrew Merenbach wrote:

Hi, Yakov,

You've already received an answer from Nick Zitzmann, but you may wish to change part of your code to:

XTensionController* cntl = [[XTensionController alloc] initWithWindowNibName:@"Converter"];

The -new method is not used much, anymore, as it is a bit clearer as to what's happening when one uses -alloc/- initWithWindowNibName. Additionally, if you do use -new, you can't use -initWithWindowNibName afterwards, since -new already performs a plain -init. So you're probably best off just using -alloc and - initWithWindowNibName, and discarding the -new.

The same applies with objects that require a standard -init.

Cheers,
	Andrew

On May 10, 2007, at 11:21 AM, Yakov Zaytsev wrote:

Hi,

I'm a Cocoa newcomer. I've just subscribed to Cocoa-dev and.. I want to allow myself probably newbie question as a first post ;)

I want to open a window from a Carbon-ized application or from plain main() like this [in order to plug in this code into "big" application]


XTensionController* cntl = [XTensionController new]; /* [cntl initWithWindowNibName:@"Converter"]; [cntl showWindow:nil]; */

    [NSBundle loadNibNamed: @"Converter.nib" owner:cntl];

    NSLog (@"window name:%@", [cntl window]);


The problem is that in any case I got nil...
Should I add some cocoa specific startup code? Yeah, besides bunch of leaks which are shown in console log..
In general is it hard to add Cocoa to a Carbon-ized application? How much set up code would be involved..


Thanks in advance for any pointers!..


--- Yakov Zaytsev Envion Software http://www.envionsoftware.com

<Talk Small and Carry a Big Class Library>





_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40ucla.edu


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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

Web Hosting by West Virginians, for West Virginians: http://wv-www.net Cocoa programming in Perl: http://camelbones.sourceforge.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Cocoa bootstrap (From: Yakov Zaytsev <email@hidden>)
 >Re: Cocoa bootstrap (From: Andrew Merenbach <email@hidden>)

  • Prev by Date: Re: Cocoa bootstrap
  • Next by Date: Focus ring not displaying while editing custom split NSCell
  • Previous by thread: Re: Cocoa bootstrap
  • Next by thread: window min/max Size and toolbar
  • Index(es):
    • Date
    • Thread