NSString NSNumber 相互转化

    NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init];
    NSNumber *firstNum = [NSNumber numberWithInt:2];
    
    //NSNumber 转为 NSString
    NSString *firstStr = [numFormatter stringFromNumber:firstNum];
    
    //NSString 转为 NSNumber
    NSNumber *secondNum = [numFormatter numberFromString:firstStr];
    
    [numFormatter release];

 

posted @ 2015-01-05 20:41  shidaying  阅读(525)  评论(0编辑  收藏  举报