NSString *testStr01=@"HelloWord";
NSString *testStr02=[testStr01 substringToIndex:];//取头(从头到哪),to不包括下标内容
NSString *testStr03=[testStr01 substringFromIndex:];//去尾(从哪到尾),from包括下标内容
NSLog(@"testStr02:%@ testStr03:%@",testStr02,testStr03); NSRange r={,};//取中间,从哪长度是多少
NSString*testStr04=[testStr01 substringWithRange:r];
NSLog(@"testStr04:%@",testStr04); //字符串的拼接
NSString *testStr05 = @"Hello";
//追加
NSString *testStr06 = [testStr05 stringByAppendingString:@"World"];
NSLog(@"testStr06:%@",testStr06);
//初始化
NSString *testStr07 = @"Hello";
NSString *testStr08 = @"World";
NSString *testStr09 = [NSString stringWithFormat:@"%@%@",testStr07,testStr08];
NSString *testStr10 = [NSString stringWithFormat:@"Hello%@",testStr08];
NSLog(@"testStr09:%@",testStr09);
NSLog(@"testStr10:%@",testStr10); //按指定格式(范围)追加内容
NSString *testStr11 = @"Hello";
NSString *testStr12 = [testStr11 stringByAppendingFormat:@"%@%@",@"World",@""];
NSLog(@"testStr12:%@",testStr12); //替换
NSString *testStr13 = @"www.kyle.com.cn";
NSString *testStr14 = [testStr13 stringByReplacingCharactersInRange:NSMakeRange(, ) withString:@""];
NSLog(@"testStr14:%@",testStr14); //编码集
//参数 文件的路径 不包括文件名
NSString *path = @"/Users/apple/Desktop";
//path = [path stringByAppendingString:@"/test.txt"];
path = [path stringByAppendingString:@"/test.rtf"];
//把文件中的内容 读取到字符串中
//NSString *str20 = [[NSString alloc]initWithContentsOfFile:path]; NSString *testStr15 = [[NSString alloc]initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; NSLog(@"testStr15:%@",testStr15); NSString* use=@"fcp";
NSString* use1=@"fcp"; NSString*password=@"";
NSString*password1=@"";
if ([use isEqualToString:use1]&&[password isEqualToString:password1]) {
NSLog(@"登陆成功");
}
else{
NSLog(@"登陆失败");
}

NSString 的常用操作的更多相关文章

  1. NSString&NSMutableString常用操作梳理(转)

    作者:弦苦 授权本站转载. 上一篇梳理了NSArray&NSMutableArray常用操作,这次来梳理一下Objective-C中每天都要用到的字符串处理类——NSString. Objec ...

  2. NSString&NSMutableString常用操作梳理

    http://www.cocoachina.com/ios/20150724/12722.html 上一篇梳理了NSArray&NSMutableArray常用操作,这次来梳理一下Object ...

  3. [Swift]字符串(String类、NSString类)常用操作

    NS是Cocoa类对象类型的前缀,来源于乔布斯建立的另一家公司--NeXTNSString的使用方法,和Swift语言中的String有很多相似之处. 1.字符串的定义String类 var str1 ...

  4. UITableView取消选中颜色、常用操作

    UITableView取消选中颜色.常用操作   使用空白view取代cell - (UITableViewCell *)tableView:(UITableView *)tableView cell ...

  5. 【三】用Markdown写blog的常用操作

    本系列有五篇:分别是 [一]Ubuntu14.04+Jekyll+Github Pages搭建静态博客:主要是安装方面 [二]jekyll 的使用 :主要是jekyll的配置 [三]Markdown+ ...

  6. php模拟数据库常用操作效果

    test.php <?php header("Content-type:text/html;charset='utf8'"); error_reporting(E_ALL); ...

  7. Mac OS X常用操作入门指南

    前两天入手一个Macbook air,在装软件过程中摸索了一些基本操作,现就常用操作进行总结, 1关于触控板: 按下(不区分左右)            =鼠标左键 control+按下        ...

  8. mysql常用操作语句

    mysql常用操作语句 1.mysql -u root -p   2.mysql -h localhost -u root -p database_name 2.列出数据库: 1.show datab ...

  9. nodejs配置及cmd常用操作

    一.cmd常用操作 1.返回根目录cd\ 2.返回上层目录cd .. 3.查找当前目录下的所有文件dir 4.查找下层目录cd window 二.nodejs配置 Node.js安装包及源码下载地址为 ...

随机推荐

  1. ASP.NET MVC5 网站开发实践(二) Member区域 - 用户部分(1)用户注册

    上一次把基本框架搭建起来了,这次开始整Web部分,终于可以看到界面了小激动一下.web项目部分从用户功能开始,基本有注册,登录.注销.查找.查看.删除等涉及Member区域和Manage区域. 目录: ...

  2. Rust初步(三):使用atom搭配racer进行rust编程

    在rust.cc社区中有一个关于rust编辑器的讨论(话说很多人要学一个新语言,都会立即考虑编辑器的问题,包括我在内),主要关注的是,智能提示(这个真的太重要了).大家讨论下来有几个选择 1. ecl ...

  3. IOS 开发中要注意的事项

    1.关于拍摄 TGCameraViewController – 基于 AVFoundation 的自定义相机.样式漂亮,轻量并且可以很容易地集成到 iOS 项目中.不会内存吃紧 2.block 中对控 ...

  4. 走进vue.js(一)

    走进vue.js(一) vue.js作为目前最具前景的前端框架之一,既然如此,博主贯彻以往的作风,肯定要捣鼓一番,经过为期半个多月的研究,算是对vue有了深刻的理解与认识,下面分三个章节解开vue.j ...

  5. C#的网络适配器操作

    网络的相关设置在项目开发中有较多的应用,有时候需要在项目中对网络信息进行相关设置. 现在提供提供几种相关的辅助方法类. (1).IP地址 /// <summary> /// IP地址 // ...

  6. 使用dynamic linq 解决自定义查询的若干弊端

    在项目中想必大家肯定是使用各种ORM, 如:NH.EF.fluent Data. 然而我在使用ORM的这几年中,随着数据库的结构越来越复杂,自定义查询的越来越多,但是一直没有解决一个问题就是自定义查询 ...

  7. const 和 readonly

    const 和 readonly 的异同 Const readonly 字面意 不变常量,不可修改 只读操作,不可写 初始化 必须在声明的同时赋值 可在声明和构造方法中进行赋值 所属关系 类.即sta ...

  8. angular.js规范写法

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  9. ADO.net数据绑定

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; usin ...

  10. javascript的 Object 和 Function

    一. javascript 的 内置对象: Object 和 Function javascript所有东西,包括 Function 都是对象 . Array  其实是一个 Function 类型的对 ...