拆分NSString以访问一个特定的片段 [英] Split an NSString to access one particular piece
本文介绍了拆分NSString以访问一个特定的片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的字符串: @10/04/2011
,我想只保存10在另一个字符串。
I have a string like this: @"10/04/2011"
and I want to save only the "10" in another string. How can I do that?
推荐答案
NSArray* foo = [@"10/04/2011" componentsSeparatedByString: @"/"];
NSString* firstBit = [foo objectAtIndex: 0];
这篇关于拆分NSString以访问一个特定的片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文