0
任何人都可以解釋爲什麼這代碼工作完美:stringWithFormat錯誤訪問錯誤
int thumbnailPrefix = trunc([newGraph.dateCreated timeIntervalSinceReferenceDate]);
newGraph.thumbnailImageName = [NSString stringWithFormat:@"%d.%@",thumbnailPrefix,@"png"];
但這種代碼導致錯誤訪問錯誤?
newGraph.thumbnailImageName = [NSString stringWithFormat:@"%d.%@",trunc([newGraph.dateCreated timeIntervalSinceReferenceDate]),@"png"];
或者,更具體地說,%d期望一個32位參數,並且trunk返回一個64位參數。因此,%@試圖將trunc()的返回值的後半部分視爲一個id和** Boom **。 – bbum
啊,我的錯。我以爲trunc返回一個整數。感謝澄清傢伙。這個網站給了我更多的信息比我所有的目標C書結合起來。 – wayne