我正在尝试根据他们的十年来列出年份。
我有这个forLoop:
for (int i = 0; i <= 9; i++) {
NSString *thisYear = [NSString stringWithFormat: @"%ld", thisDecade];
//NSLog (@"(long)selectedDecade++ %ld", (long)selectedDecade++ );
thisDecade = thisDecade ++;
NSLog (@"thisDecade %ld", thisDecade);
}
我在按钮标签中使用结果。记录输出显示标签文本和循环结果之间存在差异,我脖子酸痛试图找出原因..是循环中的东西吗?谢谢
日志:
[AppDelegate setYears]
selectedDecade: 1970
thisDecade 1971
RightSideBar aTitle is 1970
thisDecade 1972
RightSideBar aTitle is 1971
thisDecade 1973
RightSideBar aTitle is 1972
thisDecade 1974
RightSideBar aTitle is 1973
thisDecade 1975
更新 - 我感谢所有的帮助,但我仍然很难过。我附上了日志的截图,以及产生它们的代码..再次感谢..
-(void)addButtonWithTitle:(NSString*)aTitle image:(NSImage*)image alternateImage:
(NSImage*)alternateImage
{
//NSLog(@"%s", __FUNCTION__);
NSButtonCell * cell = [self addButton];
[cell setTitle:aTitle];
NSLog(@"RightSideBar aTitle is %@", aTitle); << see the logs vs the screenshot
[cell setImage:image];
[cell setAlternateImage:alternateImage];
}
日志:
UPDATE2:事实证明,我错误地对自定义单元进行了子类化,因此,调用它的次数太多了..我将标记为完整,因为你们都给了我很好的想法。我希望我们能奖励多点..