1、前言
NSString的boolValue
之前有使用,但是一直没有真正了解什么时候返回YES(true)或NO(false)。其实,苹果在官方文档中已经写的很清楚,按command
+ control
点击boolValue
进入文档就可以看到:
more >>boolValue
The Boolean value of the string.Declaration
@property(readonly) BOOL boolValue;Discussion
This property is YES on encountering one of “Y”, “y”, “T”, “t”, or a digit 1-9—the method ignores any trailing characters. This property is NO if the receiver doesn’t begin with a valid decimal text representation of a number.
The property assumes a decimal representation and skips whitespace at the beginning of the string. It also skips initial whitespace characters, or optional -/+ sign followed by zeroes.