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