How to convert NSNumber to NSString

后端 未结 7 1301
孤城傲影
孤城傲影 2020-11-29 19:25

So I have an NSArray \"myArray\" with NSNumbers and NSStrings. I need them in another UIView so i go like this:



        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 20:00

    //An example of implementation :
    // we set the score of one player to a value
    [Game getCurrent].scorePlayer1 = [NSNumber numberWithInteger:1];
    // We copy the value in a NSNumber
    NSNumber *aNumber = [Game getCurrent].scorePlayer1;
    // Conversion of the NSNumber aNumber to a String with stringValue
    NSString *StringScorePlayer1 = [aNumber stringValue];
    

提交回复
热议问题