Re: How to check if super exists if it doesn't without throwing an exception?
Re: How to check if super exists if it doesn't without throwing an exception?
- Subject: Re: How to check if super exists if it doesn't without throwing an exception?
- From: Dave <email@hidden>
- Date: Thu, 18 Jun 2015 21:58:10 +0100
> On 18 Jun 2015, at 21:26, Alex Zavatone <email@hidden> wrote:
>
>
> On Jun 18, 2015, at 4:13 PM, Jens Alfke wrote:
>
>>
>>> On Jun 18, 2015, at 1:06 PM, Alex Zavatone <email@hidden> wrote:
>>>
>>> I've got some spooky code that I'm digging into that calls an instance method in an uninstantiated timer class
>>
>> I’m not clear on what that means. If the class doesn’t have any instances, how are you calling an instance method on it?
>>
>>> Within this pearl, we have [super sendevent:event]; within an @try block.
>>> At the point of the exception, super isn't even accessible, declared or defined.
>>
>> ‘super’ isn’t an object. It’s a language keyword that’s used as the receiver of a method call (message-send). It just means to call the superclass’s implementation of the method, or more literally, “send this message to self but ignore any implementation in self’s class, instead starting lookup in the superclass.”
>>
>> If [super sendEvent:event] throws an exception, it means that the superclass does not have a -sendEvent: method.
>
> Any reason you can think of why it would intermittently throw an exception?
>
> Self's superclass is UIApplication. The only thing I can think of is that self somehow becomes undefined or changes its superclass.
Sounds like someone is releasing “Self” when they shouldn’t, but “super” isn’t an object in it’s own right, it’s part of “self”, its just they it discounts any methods of “self” and uses the methods from the Class tree that is has inherited from.
Think of it like this:
NSObject
NSSomethingOrOther : NSObject
NSSomethingElse : NSObject
Your Class: NSSomethingElse.
It builds up a map of all the methods, properties etc, super, just takes you up (down?) the chain one level.
All the Best
Dave
_______________________________________________
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