use*_*518 2 objective-c objective-c++
在这种情况下,如何将std :: string转换为NSString?
void Piles::imagePlacer(Card card, int xCoord, int yCoord) {
string cardType = card.toString();
UIImageView *cardImg = [[UIImageView alloc]
initWithImage:cardType];
cardImg.frame = CGRectMake(xCoord, yCoord, 126, 190);
[self.view addSubview:cardImg];
}
Run Code Online (Sandbox Code Playgroud)
我想使用一个字符串作为图像的名称(假设我有一个UIImages列表,其名称对应于存储在cardType中的所有可能的字符串)?
new*_*cct 12
只需浏览一下C字符串:
[NSString stringWithUTF8String:cardType.c_str()]
或使用新语法:
@(cardType.c_str())
| 归档时间: |
|
| 查看次数: |
3824 次 |
| 最近记录: |