﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-天之骄子</title><link>http://www.cppblog.com/tianzhijiaozino1/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 07 Apr 2026 23:44:39 GMT</lastBuildDate><pubDate>Tue, 07 Apr 2026 23:44:39 GMT</pubDate><ttl>60</ttl><item><title>IOS中各种数据类型转换</title><link>http://www.cppblog.com/tianzhijiaozino1/archive/2014/04/04/206464.html</link><dc:creator>天之骄子'</dc:creator><author>天之骄子'</author><pubDate>Fri, 04 Apr 2014 02:27:00 GMT</pubDate><guid>http://www.cppblog.com/tianzhijiaozino1/archive/2014/04/04/206464.html</guid><wfw:comment>http://www.cppblog.com/tianzhijiaozino1/comments/206464.html</wfw:comment><comments>http://www.cppblog.com/tianzhijiaozino1/archive/2014/04/04/206464.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/tianzhijiaozino1/comments/commentRss/206464.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/tianzhijiaozino1/services/trackbacks/206464.html</trackback:ping><description><![CDATA[<br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" />1.截取字符串<br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSString*string =@"sdfsfsfsAdfsdf";</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">string = [string&nbsp;substringToIndex:7];//截取下标7之后的字符串</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSLog(@"截取的值为：%@",string);</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">[string&nbsp;substringFromIndex:2];//截取下标2之前的字符串</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSLog(@"截取的值为：%@",string);</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" />2.匹配字符串<br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSString*string =@"sdfsfsfsAdfsdf";</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSRangerange = [stringrangeOfString:@"f"];//匹配得到的下标</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSLog(@"rang:%@",NSStringFromRange(range));</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">string = [string&nbsp;substringWithRange:range];//截取范围类的字符串</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSLog(@"截取的值为：%@",string);</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">3.分隔字符串</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSString*string =@"sdfsfsfsAdfsdf";</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSArray&nbsp;*array = [string&nbsp;componentsSeparatedByString:@"A"]; //从字符A中分隔成2个元素的数组</span><br style="outline: none; color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px;" /><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;">NSLog(@"array:%@",array); //结果是adfsfsfs和dfsdf<br /><br />小写字符转为大写字符<br /></span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; ">&nbsp;1</span>&nbsp;NSString&nbsp;*str&nbsp;=&nbsp;@"mobile&nbsp;developer&nbsp;tips";&nbsp;&nbsp;<br /><span style="color: #008080; ">&nbsp;2</span>&nbsp;&nbsp;&nbsp;&nbsp;<br /><span style="color: #008080; ">&nbsp;3</span>&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;Convert&nbsp;string&nbsp;to&nbsp;uppercase&nbsp;&nbsp;</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">&nbsp;4</span>&nbsp;<span style="color: #008000; "></span>NSString&nbsp;*upperStr&nbsp;=&nbsp;[str&nbsp;uppercaseStringWithLocale:[NSLocale&nbsp;currentLocale]];&nbsp;&nbsp;<br /><span style="color: #008080; ">&nbsp;5</span>&nbsp;NSLog(@"upperStr:&nbsp;%@",&nbsp;upperStr);&nbsp;&nbsp;<br /><span style="color: #008080; ">&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp;<br /><span style="color: #008080; ">&nbsp;7</span>&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;Convert&nbsp;string&nbsp;to&nbsp;caps&nbsp;&nbsp;</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">&nbsp;8</span>&nbsp;<span style="color: #008000; "></span>NSString&nbsp;*capStr&nbsp;=&nbsp;[upperStr&nbsp;capitalizedStringWithLocale:[NSLocale&nbsp;currentLocale]];&nbsp;&nbsp;<br /><span style="color: #008080; ">&nbsp;9</span>&nbsp;NSLog(@"capStr:&nbsp;%@",&nbsp;capStr);&nbsp;&nbsp;<br /><span style="color: #008080; ">10</span>&nbsp;&nbsp;&nbsp;&nbsp;<br /><span style="color: #008080; ">11</span>&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;Convert&nbsp;string&nbsp;to&nbsp;lowercase&nbsp;&nbsp;</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">12</span>&nbsp;<span style="color: #008000; "></span>NSString&nbsp;*lowerStr&nbsp;=&nbsp;[capStr&nbsp;lowercaseStringWithLocale:[NSLocale&nbsp;currentLocale]];&nbsp;&nbsp;<br /><span style="color: #008080; ">13</span>&nbsp;NSLog(@"lowerStr:&nbsp;%@",&nbsp;lowerStr); &nbsp;</div><span style="color: #333333; font-family: arial, 宋体; font-size: small; line-height: 19.5px; background-color: #ffffff;"><br /><br /></span><img src ="http://www.cppblog.com/tianzhijiaozino1/aggbug/206464.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/tianzhijiaozino1/" target="_blank">天之骄子'</a> 2014-04-04 10:27 <a href="http://www.cppblog.com/tianzhijiaozino1/archive/2014/04/04/206464.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>