2012-07-11 69 views
-1

可能重複:
How to assign to the nsstring object a NSString with variables?如何獲得帶有變量的NSString?

當我嘗試顯示的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); 
    } 
+1

轉發[如何分配給nsstring對象一個帶變量的NSString?](http://stackoverflow.com/questions/11420100/how-to-assign-to-the-nsstring-object-a-nsstring-與變量) – 2012-07-11 06:47:53

回答

0

你必須使用格式符%ld表示指定長

allTime = [NSString stringWithFormat:@"%02i:%02i", mins, secs]; 

..

這樣的..

[NSString stringWithFormat:@"%ld/%ld", mins, secs];