• 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: Main menu crash when migrating to Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Main menu crash when migrating to Leopard


  • Subject: Re: Main menu crash when migrating to Leopard
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 23 Dec 2008 11:41:17 -0800

On Dec 23, 2008, at 04:32, Klaus Backert wrote:

The cause of the crash is the following category, I had implemented, overriding a method of NSObject's NSKeyValueCoding category:

@interface NSObject (MyKeyValueCoding)
+ (BOOL)accessInstanceVariablesDirectly;
@end

@implementation NSObject (MyKeyValueCoding)
+ (BOOL)accessInstanceVariablesDirectly { return NO; }
@end

After having deleted this category, the application works again.

Well, there have been warnings on this mailing list about overriding methods of Cocoa categories. I did it at my own risk. Apparently it's too much stopping direct access of instance variables in key- value coding for *each* and *every* class.

Well, there are actually two very major problems with the approach you tried to use.


First, if you take away direct access to instance variables, then *all* classes that depend on it (and there are lots of them) will break. Randomly "deleting" functionality of existing classes is sure to be a bad idea. (If you want to disable the functionality in all *your* classes, the correct way would be to subclass NSObject, and then derive all your classes from this NSObject subclass.)

Second, many methods defined on NSObject (in particular, most KVC/KVO methods) are defined as categories. You can't reliably replace a method in one category by redefining the method in another category, because the order in which the categories are applied to their class is undefined. (Again, subclassing is the way to go, if you want to override a method that might be defined in a category.)


_______________________________________________

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


References: 
 >Re: Main menu crash when migrating to Leopard (From: Klaus Backert <email@hidden>)

  • Prev by Date: Re: Debugging memory smashers with GC
  • Next by Date: Re: Debugging memory smashers with GC
  • Previous by thread: Re: Main menu crash when migrating to Leopard
  • Next by thread: Rotating a CALayer more than once is not working
  • Index(es):
    • Date
    • Thread