Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7576693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:59:03+00:00 2026-05-30T16:59:03+00:00

I had to detect if user has touched on the iPhone screen. So, I

  • 0

I had to detect if user has touched on the iPhone screen. So, I created a class named “CustomApplication” in my project (subclassing UIApplication) and then, I modified my main.m to look like this:

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, @"CustomApplication",nil);
[pool release];
return retVal;

This class “CustomApplication.m” contains a method as follows:

- (void)sendEvent:(UIEvent *)event {
[super sendEvent:event];
[MyUtility showAlertWithTitle:@"Alert!!!!" message:@"Session Expired!!!!"]; // showing an alert here
}

The Method showAlertWithTitle looks like this:

+ (void) showAlertWithTitle:(NSString *)aTitle message:(NSString *)aMessage
{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:aTitle message:aMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show]; // Line causing problem in iOS 5 - base sdk 5.0
[alertView release];

}

Everythings working fine in iOS 4.2, but on iOS 5.0 the app is crashing on touching the screen (when sendEvent:event method gets called). When I debugged the code, I found that the problem is in [alertView show]; line. In iOS 5, what is happening is when this particular line ([alertView show];) gets executed, it again calls sendEvent method of CustomApplication and this method calls showAlertWithTitle: method of MyUtility which in turn again calls sendEvent method and hence, the code is entering into infinite loop. I dont know the solution. If someone has faced this weired thing, then please tell me what should I write so that when alert is being showed the sendEvent method doesn’t get called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:59:04+00:00Added an answer on May 30, 2026 at 4:59 pm

    This may not seem like the best approach, but It may work. Have you tried simply including a static boolean variable in your code, so that the function does not get called again?

    Somewhere up

    BOOL stopHere = NO;
    

    And then the sendEvent

    -(void)sendEvent:(UIEvent *)event{
        [super sendEvent:event];
        if (!skipHere){
            skipHere = YES;
            [MyUtility showAlertWithTitle:@"Alert!!!!" message:@"Session Expired!!!!"]; // show        
        skipHere=NO;
        }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to detect when a user has finished scrolling a web page
I am trying to detect if a user on my page has cookies enabled
i had a javascript to detect user broswer width and want to pass the
VS 2008 I am developing an application that has to detect whether a client
I'm wondering if anyone has had any experience with the API that gives you
How can I detect whether or not an Image View has a picture in
I want to be able to detect if my app has been set to
Not sure if anyone has had experience with a good solution to rendering templates
My iPhone app has a tab bar controller, and one of the tabs is
How would I detect if an element had two parent uls so for example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.