On Jun 23, 2015, at 10:50 PM, Kyle Sluder wrote:

>> On Jun 23, 2015, at 7:31 PM, Alex Zavatone <z...@mac.com> wrote:
> 
>> 
>> 
>> On Jun 23, 2015, at 9:27 PM, Kyle Sluder wrote:
>> 
>>>> On Jun 23, 2015, at 6:10 PM, Alex Zavatone <z...@mac.com> wrote:
>>>> 
>>>> Actually, the rotate event is the one that is being caught and sent.
>>>> 
>>>> If it's a UIEvent and it's listed as a UIInternalEvent, within the 
>>>> debugger, how do I check the type and subtype to see what type of event it 
>>>> is so that I can return immediately if it is the wrong type?
>>> 
>>> I don’t understand the question. Or rather, I understand the question, but 
>>> I don’t understand why you are asking it.
>> 
>> Because an exception is thrown in that case and I'd prefer to return before 
>> my app quits.
> 
> It’s your code that’s throwing the exception, right? Or are you saying that 
> UIKit is throwing an exception if you ask for the .type of a UIEvent that it 
> hands you, if that object just so happens to be an instance of a private 
> subclass?
> 
>> 
>>> There are three public types of event: Touches, Motion, and RemoteControl. 
>>> Are you saying that UIInternalEvents are re-using one of these constants, 
>>> and therefore you need an alternative way to disambiguate them? That’s 
>>> definitely a problem and you should file a Radar.
>> 
>> I'm saying "I want to see which event it is and return if it is a motion 
>> event".
> 
> Assuming the exception is being thrown by your code, stop doing that and just 
> check the event’s .type. If it isn’t equal to Motion, skip it.
> 

It's not being thrown by my own code.  It's a rotate event that's being sent by 
the system.  

I did that.  I'm telling you that "it doesn't work".

The event's type doesn't match the enums.  The event's type doesn't match any 
enum that I know of.  I'm asking "how can I check this?"

All I can get is a -1 of type and a 0 of subtype for any event that's sent 
through this event catching class that I had no part in writing.  I'm trying to 
see what type of event this is so I can exit gracefully before the app blows up 
on me in this special case.

>> 
>>> 
>>> If you just want to spelunk around the innards of a private UIEvent 
>>> subclass, then no. We will not provide you information to do so.
>>> 
>>> Barring that, just do if (event.type==UIEventTypeMotion) { } else if 
>>> (event.type==UIEventTypeTouches) { } …
>> 
>> Yeah, I tried that.  The event.type is returning -1 and isn't matching any 
>> of the 3 UIEventType enum values.  It's not matching on any of them.
> 
> There is no guarantee that the event type will be a member of the public 
> enum. Your code needs to be prepared for this case. A future OS might add a 
> new event type. You don’t want your existing, shipping apps to blow up when 
> the user upgrades their OS.
> 
> --Kyle Sluder

Um, but I'm asking "how can I prepare for this case?"

This is for a motion event.  The OS is throwing the event.  I'm not.  My code 
is not.  It's being sent when I turn the device.   There is no orientation code 
in my viewController or nav controller. If I'm wrong and there is another thing 
I should be checking for besides the UIEventType enums (sorry, not in front of 
that computer at the moment), can you please give me a hint as to what I should 
check against?

The app is already blowing up in one case with a UIEvent being sent to super 
which is UIApplication.  This causes a bad access exception that I'd like to 
stop from bringing down my app.  I have no code that's causing the event to be 
sent, it's being done by the system and in this class that I didn't write that 
catches all events, I'd like to determine which type of event this is and exit 
before my app explodes and dies in a fire.

Do you have any suggestions how might I go about doing that?

For a UIEvent that is issued by the system as a result of rotating the iOS 
device  and is showing itself as a UIInternalEvent in the debugger, if checking 
for (event.type==UIEventTypeMotion) { } else if 
(event.type==UIEventTypeTouches) {} … fails, how can I determine the event type 
so I can have my app not throw an exception?

The problem here is that the exception is being raised within an @try block and 
it is not being caught by @catch.  The exception is raised on [super 
sendEvent:event]; only in the case of a device rotation.

It's this
@try {
    [super sentEvent:event];
}
@catch (NSException *exception){
  NSLog(@"Exception: %@",exception);
}

It never gets to @catch.  The stack trace tells me it's a call out from purple 
from a device rotation.  This is why I'm trying what you suggested.  As far as 
I can tell, this is how you are supposed to check for an event's type.  

How else might you suggest escape from the condition before the exception is 
thrown if I can't check the event's type?  

Thanks much.
_______________________________________________

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

Reply via email to