gad*_*tmo 3 xcode objective-c ios
我是iOS编程的新手.
我"Incompatible integer to pointer conversion sending 'int' to parameter of type 'NSString *'"尝试运行以下代码时收到错误:
- (IBAction)oneToSix {
int rNumber = arc4random() % 6;
[result setImage:[UIImage imageNamed: rNumber]];
}
Run Code Online (Sandbox Code Playgroud)
在将其发送到方法之前,您需要将其转换int为a .这是因为a 作为参数而不是a .试试这个:NSStringimageNamedimageNamedNSStringint
- (IBAction)oneToSix {
int rNumber = arc4random() % 6;
[result setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d", rNumber]]];
}
Run Code Online (Sandbox Code Playgroud)
更多信息:UIImage类参考.
| 归档时间: |
|
| 查看次数: |
4942 次 |
| 最近记录: |