如何检测空间,以及特殊字符如:,?,`,〜,等在iPhone SDK的文本中的文本? [英] How to detect space, and special characters like :, ?,`,~, etc in text of a textfield in iPhone SDK?

查看:120
本文介绍了如何检测空间,以及特殊字符如:,?,`,〜,等在iPhone SDK的文本中的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iPhone SDK的文本框中检测空格和特殊字符,如:,?,`,〜,等等。

How to detect space, and special characters like :, ?,`,~, etc in text of a textfield in iPhone SDK?

推荐答案

尝试这个。

NSCharacterSet* symbols = [NSCharacterSet symbolCharacterSet];
   if([symbols characterIsMember: yourCharacter]) {
        //Check Your condition here
    }

如果要包含许多字符,请将NSCharacterset与NSMutableCharacterSet组合使用。

If you want to include many characters Use a combined NSCharacterset with NSMutableCharacterSet..

    NSMutableCharacterSet *space = [NSMutableCharacterSet characterSetWithCharactersInString:@" "];
    [space formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];

使用空格字符集检查字符

Use the space characterset to check the character

这篇关于如何检测空间,以及特殊字符如:,?,`,〜,等在iPhone SDK的文本中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆