How Can I Easily Beep at the User When Input is Rejected?

Discussion in 'iOS Programming' started by kaydell.leavitt, Apr 21, 2010.

  1. kaydell.leavitt macrumors regular

    Joined:
    Apr 19, 2010
    #1
    I want to play a sound to the user when I reject their input.

    (Like the old function SysBeep() for classic Mac OS).

    I need to learn how to play a simple sound that is consistent across apps to tell the user that their input was not accepted.

    Any ideas?

    -- Kaydell
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    Do you even own an iPhone? Which apps play a sound to indicate rejected input? What happens when the phone is on silent? The answers to these questions should make it clear whether you should be doing this or not.

    Oh and forget anything about classic Mac programming. This is nothing like that.
     
  3. kaydell.leavitt thread starter macrumors regular

    Joined:
    Apr 19, 2010
    #4
  4. kaydell.leavitt thread starter macrumors regular

    Joined:
    Apr 19, 2010
    #5
    Alerts are Better Than Beeping

    OK, I'll forget beeping at the user and put up an alert.

    Do you agree that I'm on the right track?

    Code:
    void alert(NSString *title, NSString *message) {
    	UIAlertView *alert = [[UIAlertView alloc]
    		initWithTitle: title
    		message: message
    		delegate: nil
    		cancelButtonTitle: @"OK"
    		otherButtonTitles: nil
    	 ];
    	[alert autorelease];
    	[alert show];
    } 
    
     
  5. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Unless you have to show an alert don't. Can you not simply discard the input you don't want?
     
  6. kaydell.leavitt thread starter macrumors regular

    Joined:
    Apr 19, 2010
    #7
    OK.
     
  7. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    Also if possible use one of the provided keyboards that, as much as possible, only has the characters you want. If you need one or two additional keys use the notifications for the keyboard appearing/disappearing to add your own view with the additional key/keys.

    To be honest I've lost track of exactly what you want. iirc you basically want UIKeyboardTypeNumberPad with a couple of extra keys...
     
  8. kaydell.leavitt thread starter macrumors regular

    Joined:
    Apr 19, 2010
    #9
    I've decided to "go with the grain" and use the ASCII keyboard. I have some error-checking in case the user types in bad characters. I think that my orginal approach was't as good because there are other decimal points etc, I'll let the user select their locale in the System Preferences and then let the NSNumberFormatter do the conversions from and to NSString from doubles and now, I don't have to worry about filtering individual characters since that might break things for some locales.

    I think that I'm done with my simple app and I'm going to make it free and then make a 99 cent version and sell it at the app-store.

    I believe that I will sell more if I have a free app and then sell an upgrade to a paid app.

    -- Kaydell
     

Share This Page