Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何使用变量获取NSString?_Objective C_C - Fatal编程技术网

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];
转售