网络篇----截取字符

例如:

从一个链接中截取字段 oppo_N1mini

例如:source==<a href=http://app.weibo.com/feed/2llosp rel="nofollow">oppo_N1mini</a>

 -(void)setSource:(nsstring *)source

{

  //表示截取的范围

  NSRange range;

  //截取的开头

  range.location=[source rangeOfString@">"].location+1;

//到哪个地方结束

range.length=[source rangeOfString@"</"].location-range.location;

//source substringwithRange:range  截取出来的文字

_source=[NSString stringWithFormat@"来自%@",[source substringwithRange:range]];

 

}

posted @ 2015-09-09 11:54  Lee_M  阅读(136)  评论(0编辑  收藏  举报