Re: Category errata in Objective-C

2019-03-29 Thread Cody Garvin
Just for clarification, an empty name in the parens is referred to as an 
extension and not a nameless category. An extension has extra abilities such as 
adding properties. Just being explicit for those that may not know. 

Please excuse mobile typos

> On Mar 29, 2019, at 5:55 PM, Jens Alfke  wrote:
> 
> 
> 
>> On Mar 29, 2019, at 2:51 PM, Alex Zavatone  wrote:
>> 
>> Also, I seem to remember the esteemed Jens stating that as soon as a 
>> category class is in your project, it applies to all objects instantiated 
>> from the base class and we only had to do an import if we wanted to use the 
>> category methods in the debugger.  Please correct me if I am wrong here.
> 
> No, you have to #import the header if you want to use the category methods in 
> a source file.
> 
> At _compile_ time, when you call one of those methods the compiler needs to 
> have seen a prior declaration of that method or it'll flag an error. Thus, 
> you need to have #included the header file declaring the category. (The 
> compiler _could_ go ahead and decide you know what's right, and just compile 
> a call to that method anyway; back in the old days it used to, but that 
> turned out to lead to lots of stupid runtime crashes caused by mistyped 
> method names.)
> 
> At _runtime_, the category patches the class implementation when your app 
> starts, so its methods are available everywhere.
> 
> —Jens
> ___
> 
> 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/cody%40servalsoft.com
> 
> This email sent to c...@servalsoft.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: Category errata in Objective-C

2019-03-29 Thread Jens Alfke


> On Mar 29, 2019, at 2:51 PM, Alex Zavatone  wrote:
> 
> Also, I seem to remember the esteemed Jens stating that as soon as a category 
> class is in your project, it applies to all objects instantiated from the 
> base class and we only had to do an import if we wanted to use the category 
> methods in the debugger.  Please correct me if I am wrong here.

No, you have to #import the header if you want to use the category methods in a 
source file.

At _compile_ time, when you call one of those methods the compiler needs to 
have seen a prior declaration of that method or it'll flag an error. Thus, you 
need to have #included the header file declaring the category. (The compiler 
_could_ go ahead and decide you know what's right, and just compile a call to 
that method anyway; back in the old days it used to, but that turned out to 
lead to lots of stupid runtime crashes caused by mistyped method names.)

At _runtime_, the category patches the class implementation when your app 
starts, so its methods are available everywhere.

—Jens
___

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


Tool tips for column headers of NSTableView not showing

2019-03-29 Thread James Walker
I have a view-based NSTableView with column headers, and I have assigned 
tool tips to all the columns in the nib.  The problem is that if I pause 
the mouse over column headers, the tool tips don't appear.  In contrast, 
tool tips for controls within table rows work fine.  However, if I click 
one of the columns headers, then the tool tips for all the column 
headers start working.  Or, if I just activate some other app and then 
go back to mine, the tool tips start working.  These clues made me 
suspect that it had something to do with window activation or first 
responder, but I checked that in the problematic case, the table is 
first responder and its window is main.


This is on High Sierra, if it matters.
___

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: Category errata in Objective-C

2019-03-29 Thread Ben Kennedy
> On 29 Mar 2019, at 2:51 pm, Alex Zavatone  wrote:
> 
> In all the docs on categories, I seem to have missed what the term for the 
> text within the parens of a category declaration is called and what function 
> it serves.

It's the category name. NSObject(Foo) represents "the Foo category on NSObject".

As for what function it serves, well, that's a good question. I've never been 
aware of a runtime method for extracting such information or testing its 
presence (as one can for protocol conformation, for example).

> Also, I seem to remember the esteemed Jens stating that as soon as a category 
> class is in your project, it applies to all objects instantiated from the 
> base class

Categories are like a benevolent disease: once linked and loaded, they live 
everywhere.

> and we only had to do an import if we wanted to use the category methods in 
> the debugger.  Please correct me if I am wrong here.
> 
> But I found out that that is not true.  You have to import the category 
> header into any classes where you want to take advantage of the category 
> methods you added to a specific class.

These amount to the same thing, which is exposing the symbol names to your 
interpreter or compiler for your convenient use as a programmer.

-ben

___

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


Category errata in Objective-C

2019-03-29 Thread Alex Zavatone
In all the docs on categories, I seem to have missed what the term for the text 
within the parens of a category declaration is called and what function it 
serves.  

Any idea?

Also, I seem to remember the esteemed Jens stating that as soon as a category 
class is in your project, it applies to all objects instantiated from the base 
class and we only had to do an import if we wanted to use the category methods 
in the debugger.  Please correct me if I am wrong here.

But I found out that that is not true.  You have to import the category header 
into any classes where you want to take advantage of the category methods you 
added to a specific class.  The import can be done on a specific file level, 
into a .pch if you want your whole app/module to be able to take advantage of 
the methods.  

Did I misread Jens’s statement?

Cheers,
Alex Zavatone



Sent from my iPad
___

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