调试日志如下所示。
2013-06-09 17:09:09.192 BridgeDeal[2430:11303] suito: 2K
2013-06-09 17:09:09.193 BridgeDeal[2430:11303] suit: 50
2013-06-09 17:09:09.193 BridgeDeal[2430:11303] suito: 2Q
2013-06-09 17:09:09.193 BridgeDeal[2430:11303] suit: 50
2013-06-09 17:09:09.194 BridgeDeal[2430:11303] suito: 3J
2013-06-09 17:09:09.194 BridgeDeal[2430:11303] suit: 51
上面的值suito
是正确的,但不是suit
上面的值。相反,suit
我希望得到 2,2,3 的值。
for (int i = 0; i<3; i++) {
NSInteger suit = [[self.cardList objectAtIndex:i ] characterAtIndex:0] ;
NSLog(@"suito: %@", [self.cardList objectAtIndex:i ]);
NSLog(@"suit: %d", suit);
}
cardlist
声明如下。
@property (nonatomic, weak) NSMutableArray *cardList;
我尝试了以下代码,但收到错误:bUnexpected type name 'NSRange'
NSInteger suit = [[self.cardList objectAtIndex:i ] substringWithRange:NSRange(0,1)] ;