Objective c 如何使用变量获取NSString?
可能重复:Objective c 如何使用变量获取NSString?,objective-c,c,Objective C,C,可能重复: 当我尝试显示nsstring对象时,我得到以下结果: 总时间:l 相反,我想要的是:02:35 怎么做?谢谢大家! allTime = [NSString stringWithFormat:@"%l/%l", mins, secs]; for(Playlists *thePL in collection) { NSLog(@"===NEXT PLAYLIST==="); NSLog(@"Name: %@", thePL.namePL);
当我尝试显示nsstring对象时,我得到以下结果: 总时间:l 相反,我想要的是:02:35 怎么做?谢谢大家!
allTime = [NSString stringWithFormat:@"%l/%l", mins, secs];
for(Playlists *thePL in collection)
{
NSLog(@"===NEXT PLAYLIST===");
NSLog(@"Name: %@", thePL.namePL);
NSLog(@"Quantity of songs: %i", thePL.entries);
NSLog(@"Total of time: %@",thePL.allTime);
}
假设
mins
和secs
是整数:
allTime = [NSString stringWithFormat:@"%02i:%02i", mins, secs];
如果需要更多信息,请搜索,您必须使用格式说明符%ld来指定long 像这样
[NSString stringWithFormat:@"%ld/%ld", mins, secs];
转售