Re: Another dumb question about NSWindowController(s)

2014-06-08 Thread Eric Shepherd
Anyone have awesome templates to share? :)

Eric Shepherd
Sent from my iPhone

> On Jun 8, 2014, at 9:04 PM, Shane Stanley  wrote:
> 
>> On 9 Jun 2014, at 10:16 am, Graham Cox  wrote:
>> 
>> I really wish Xcode would allow us to make our own templates, even for NSxxx 
>> classes.
> 
> You can. Copy this: 
> 
> /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File 
> Templates/Cocoa/Objective-C class.xctemplate
> 
> To here:
> 
> ~/Library/Developer/Xcode/Templates/Cocoa/Objective-C custom class.xctemplate
> 
> Then edit the copied templates to your heart's content.
> 
> When you go to add a new file in Xcode, you'll see your new category of 
> template listed.
> 
> -- 
> Shane Stanley 
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/the.sheppy%40gmail.com
> 
> This email sent to the.she...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Another dumb question about NSWindowController(s)

2014-06-08 Thread Graham Cox

On 9 Jun 2014, at 11:04 am, Shane Stanley  wrote:

> You can.


Thanks! There's my morning's productivity gone, but I fully expect it to pay 
itself back.

--Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Another dumb question about NSWindowController(s)

2014-06-08 Thread Shane Stanley
On 9 Jun 2014, at 10:16 am, Graham Cox  wrote:

> I really wish Xcode would allow us to make our own templates, even for NSxxx 
> classes.

You can. Copy this: 

/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File 
Templates/Cocoa/Objective-C class.xctemplate

To here:

~/Library/Developer/Xcode/Templates/Cocoa/Objective-C custom class.xctemplate

Then edit the copied templates to your heart's content.

When you go to add a new file in Xcode, you'll see your new category of 
template listed.

-- 
Shane Stanley 



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Another dumb question about NSWindowController(s)

2014-06-08 Thread Eric Shepherd
On Jun 8, 2014, at 8:16 PM, Graham Cox  wrote:
> 
> 
>> On 8 Jun 2014, at 7:32 am, Lee Ann Rucker  wrote:
>> 
>> Delete that init method. Xcode has a standard template and doesn't change it 
>> when you tick the "make a xib file" checkbox.
> 
> 
> I really wish Xcode would allow us to make our own templates, even for NSxxx 
> classes. The templates they do come with are rarely useful,

This. This, this, this. A thousand times, this. I've never not found these 
templates more harmful than helpful. They're especially damaging for newbies, 
who learn Bad Things by following advice given in the comments in the existing 
templates.

Eric Shepherd
Sent from my iPhone
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Another dumb question about NSWindowController(s)

2014-06-08 Thread Graham Cox

On 8 Jun 2014, at 7:32 am, Lee Ann Rucker  wrote:

> Delete that init method. Xcode has a standard template and doesn't change it 
> when you tick the "make a xib file" checkbox.


I really wish Xcode would allow us to make our own templates, even for NSxxx 
classes. The templates they do come with are rarely useful, often give you a 
bunch of methods that you don't always need to override whatever the comments 
say, give you the wrong initializers, and the thing that bugs me the most, 
gives you a coding style that is not the one I like to use. As they are, they 
more or less manage to do nothing but give you extra work to correct.

--Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Another dumb question about NSWindowController(s)

2014-06-07 Thread Seth Willits

initWithWindow: is the designated initializer which is why the template has it 
vs one other of the init methods, but it doesn't mean you have to use it. It's 
not there to tell you that you need to call it, it's there so you can add 
initialization-time code as needed.

The easiest thing to do to get a window controller to load from a nib 
automatically is just implement -windowNibName. (In 10.10 you won't need to 
even bother if the xib is named the same as the class.)

Nothing magical going on. You (as an example) call alloc] init], it calls 
initWithWindow: passing nil (because it's the designated initializer). You ask 
for the wc's window at some point, it realizes it doesn't have one, sees 
windowNibName, loads from the nib, and calls windowDidLoad. Baddabing badda 
boom.



--
Seth Willits




On Jun 7, 2014, at 12:24 PM, William Squires  wrote:

>  Okay, if I create a new NSWindowController subclass (and tell Xcode to 
> generate the .xib as well), it gives me simple (too simple, I think) template 
> code, whose init... method takes an NSWindow reference. Where does this come 
> from (the reference)?
> 
> • Is the code instantiating the custom NSWindowController subclass supposed 
> to allocate the NSWindow reference, and - if so - how? I thought the 
> controller was supposed to mediate interactions between the UI and any models 
> or other controllers, according to MVC; other code shouldn't have to worry 
> about how or where the window comes from.
> • Or is this one of those "magical" things that's automatically hooked up 
> when the .xib gets unarchived? If so, how, since I would think the controller 
> would have to load the .xib first, and the template code simply contains no 
> reference to loading (any) xib!
> 
>  Unfortunately, all my "program in MacOS X" books are really out-of-date; 
> what with all the publishers focusing on either Android or iOS these days... 
> :( (a look about in Barnes & Noble the other day revealed NO books on OS X 
> programming.)
>  Could someone on this list please help me understand how a window, and its 
> controller, are supposed to be loaded/instantiated/unarchived (that's not in 
> the MainMenu.xib, but in a separate set of files (the header, implementation, 
> and xib, all related by the class name)?
> 
> P.S. This is with Xcode 5.1.1 on MacOS X 10.8, compiling for MacOS X 64 bit, 
> 10.7 SDK.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Another dumb question about NSWindowController(s)

2014-06-07 Thread Lee Ann Rucker
Delete that init method. Xcode has a standard template and doesn't change it 
when you tick the "make a xib file" checkbox. Replace it with

- (id)init
{
   return [self initWithWindowNibName:@"myGeneratedNibFileName"];
}


There are plenty of sample apps you can download from Apple that use windows in 
separate nibs; if you search for initwithwindownibname you'll find several of 
them. Cocoa isn't that easy to just start from scratch with (which is one of 
the reasons for Swift); I rarely start with the "new application" template, I 
find some useful sample and start modifying it.

- Original Message -
From: "William Squires" 
To: "Cocoa Developers" 
Sent: Saturday, June 7, 2014 12:24:02 PM
Subject: Another dumb question about NSWindowController(s)

  Okay, if I create a new NSWindowController subclass (and tell Xcode to 
generate the .xib as well), it gives me simple (too simple, I think) template 
code, whose init... method takes an NSWindow reference. Where does this come 
from (the reference)?

• Is the code instantiating the custom NSWindowController subclass supposed to 
allocate the NSWindow reference, and - if so - how? I thought the controller 
was supposed to mediate interactions between the UI and any models or other 
controllers, according to MVC; other code shouldn't have to worry about how or 
where the window comes from.
• Or is this one of those "magical" things that's automatically hooked up when 
the .xib gets unarchived? If so, how, since I would think the controller would 
have to load the .xib first, and the template code simply contains no reference 
to loading (any) xib!

  Unfortunately, all my "program in MacOS X" books are really out-of-date; 
what with all the publishers focusing on either Android or iOS these days... :( 
(a look about in Barnes & Noble the other day revealed NO books on OS X 
programming.)
  Could someone on this list please help me understand how a window, and its 
controller, are supposed to be loaded/instantiated/unarchived (that's not in 
the MainMenu.xib, but in a separate set of files (the header, implementation, 
and xib, all related by the class name)?

P.S. This is with Xcode 5.1.1 on MacOS X 10.8, compiling for MacOS X 64 bit, 
10.7 SDK.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://urldefense.proofpoint.com/v1/url?u=https://lists.apple.com/mailman/options/cocoa-dev/lrucker%2540vmware.com&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yJFJhaNnTZDfFSSz1U9TSNMmxGyib3KjZGuKfIhHLxA%3D%0A&m=k%2FakAPc5IK5NJVzqMjwtzYLBhNM5wfOiBUVCrkBCutQ%3D%0A&s=d7a6014cb6ae915342e5d83321d12827ea04320235ea1d8629562b8b19c10996

This email sent to lruc...@vmware.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Another dumb question about NSWindowController(s)

2014-06-07 Thread William Squires
  Okay, if I create a new NSWindowController subclass (and tell Xcode to 
generate the .xib as well), it gives me simple (too simple, I think) template 
code, whose init... method takes an NSWindow reference. Where does this come 
from (the reference)?

• Is the code instantiating the custom NSWindowController subclass supposed to 
allocate the NSWindow reference, and - if so - how? I thought the controller 
was supposed to mediate interactions between the UI and any models or other 
controllers, according to MVC; other code shouldn't have to worry about how or 
where the window comes from.
• Or is this one of those "magical" things that's automatically hooked up when 
the .xib gets unarchived? If so, how, since I would think the controller would 
have to load the .xib first, and the template code simply contains no reference 
to loading (any) xib!

  Unfortunately, all my "program in MacOS X" books are really out-of-date; 
what with all the publishers focusing on either Android or iOS these days... :( 
(a look about in Barnes & Noble the other day revealed NO books on OS X 
programming.)
  Could someone on this list please help me understand how a window, and its 
controller, are supposed to be loaded/instantiated/unarchived (that's not in 
the MainMenu.xib, but in a separate set of files (the header, implementation, 
and xib, all related by the class name)?

P.S. This is with Xcode 5.1.1 on MacOS X 10.8, compiling for MacOS X 64 bit, 
10.7 SDK.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com