Note that there are some explanatory texts on larger screens.

plurals
  1. POUITextField - Prevent user from typing non-standard characters (like Emoticons)
    primarykey
    data
    text
    <p>My app creates and stores <code>EKEvents</code> into the standard Calendar database, however, I've found that if I use an emoticon as the "notes" for an event, it causes a crash when trying to read the event out of the Calendar.</p> <p>I don't <em>want</em> or <em>need</em> the use of emoticons in the <code>event.notes</code>. I just happened to be testing and was kind of shocked when it let me save the event. (The emoticons even show up in the Calendar itself)</p> <p>So I think my problem can be solved one of 2 way, neither of which I've been able to figure out.</p> <p><strong>1) Can I disable or hide the custom keyboard button?</strong> &lt;--I'd prefer this solution</p> <p><img src="https://i.stack.imgur.com/dCAEx.jpg" alt="enter image description here"></p> <p><strong>2) If not, how do I create a character set that includes all of the possible characters in all of the standard keyboards to check against when making sure the user does not type an emoticon?</strong></p> <p>I've tried using some of the standard character sets to check against, like <code>alphanumericCharacterSet</code>, but using that, I can't type in spaces.</p> <p>Here's the code I'm using so far, to check against the character the user is typing:</p> <pre><code>- (BOOL)textField:(UITextField *)theTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (string.length == 0) { return YES; } NSCharacterSet *myCharSet = [NSCharacterSet alphanumericCharacterSet]; for (int i = 0; i &lt; [string length]; i++) { unichar c = [string characterAtIndex:i]; if ([myCharSet characterIsMember:c]) { return YES; } } UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Invalid Input" message:@"Oops! You can't use that character." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [av show]; return NO; } </code></pre> <p><strong><em>EDIT: Clarification on the error</em></strong></p> <p>There is no error, only a crash. My app saves calendar events, and displays them in a list to the user. The user can then mark the event as "Paid" or "Unpaid" at which time I append a string to the <code>.notes</code> property of the event " - Paid". This is so when I reload the table, if the event is paid, it displays a specific icon to the user. The crash happens when the saved even has an emoticon as the <code>.notes</code> property, and I try to append the <code>.notes</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload