NSScanner 学习

文档学习

  • A string parser that scans for substrings or characters in a character set, and for numeric values from decimal, hexadecimal, and floating-point representations.

  • parser 分析程序;语法剖析程式

  • scans for 扫描

  • hexadecimal 十六进制

  • 总体翻译:这个程序扫描字符集里面的子字符或者字符串,或者来自小数、十六进制、以及浮点数里面的数字值

  • An NSScanner object interprets and converts the characters of an NSString object into number and string values. You assign the scanner’s string when you create the scanner, and the scanner progresses through the characters of that string from beginning to end as you request items.

  • progresses through 进步通过

  • 浏览器对象将一个字符对象的字符翻译和转变为数字和字符值注意这里的字符不是NSString。

  • Because of the nature of class clusters, a scanner object isn’t an actual instance of the NSScanner class, but is one of its private subclasses. Although a scanner object’s class is private, its interface is public, as declared by this abstract superclass, NSScanner. The objects you create using this class are referred to as scanner objects (and when no confusion will result, merely as scanners).

  • clusters 族群

  • confusion 混淆,混乱

  • merely 仅仅

  • 大体意思是,类是私类,但是接口确实公开的,没完全理解

  • To set an NSScanner object to ignore a set of characters as it scans the string, use the charactersToBeSkipped property. Characters in the skip set are skipped over before the target is scanned. The default set of characters to skip is the whitespace and newline character set.

  • 能跳过部分字符

  • 默认的是空格和返回键

  • To retrieve the unscanned remainder of the string, use [[scanner string] substringFromIndex: [scanner scanLocation]].

  • retrieve 检索和恢复

  • 获取剩余得未扫描的字符,使用 [[scanner string] substringFromIndex: [scanner scanLocation]].
    这个方法

方法学习

  • caseSensitive 区分大小写设置
  • scanLocation 下次开始的位置
  • charactersToBeSkipped 被跳过的字符集合,默认是空格和回车键
  • scanCharactersFromSet:intoString 按集合set里面内容扫描
  • scanUpToCharactersFromSet:intoString 与上面临近的方法相反
  • 扫描数字
    当执行扫描方法时,当前的扫描位置的字符必须是数字的开头(扫描HEX则是要0x或者0X开头),不符合条件扫描不成功
    这个判断不一定对。

优秀博客推荐

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值