NSString

NSString中包含字符

[dic[@"content"] rangeOfString:@"#"].length>0;

//根据文件名获取完整路径

+(NSString*)pathWithFileName:(NSString*)name

{

//获取路径对象

NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);

//获取完整路径

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *plistPath = [documentsDirectory stringByAppendingPathComponent:name];

return plistPath;

}

把NSString中得某几个字标红用得是NSMutableAttributedString这个类

NSString *str=@"我想把你好这二个字标红";

NSMutableAttributedString *attribute=[[NSMutableAttributedString alloc]initWithString:str];

[attribute setAttributes:@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:17]} range:NSMakeRange(3,2)];

label.attributedText=attribute;

//怎么测试iphone中支持的语言

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSArray *languages = [defaults objectForKey:@"AppleLanguages"];

NSLog(@"%@", languages);

//NSLocalizedString的用法

//括号里第一个参数是要显示的内容,与各Localizable.strings中的id对应

//第二个是对第一个参数的注释,一般可以为空串

[_alertView setTitle:NSLocalizedString(@"Submitted successfully",@"")];

你可能感兴趣的:(NSString)