2012-08-30 57 views
0

我正在做一個按數字算術處理數字的類(即對任意大小的數字進行算術)。For循環計數器返回null?

我有這個循環在運行時崩潰,並抱怨「列」爲空。任何人都可以對此有所瞭解嗎?

for(column=0; column < bigger.length; column++) { 
    NSLog(@"column %@", column); 
    workingDigit = [y intAt:column] + [self intAt:column] + carry; 
    carry = workingDigit/10;  //make the carry not include the last digit of the sum 
    workingDigit = workingDigit % 10;  //make the digit not include the carry 

    [result insertString:[NSString stringWithFormat:@"%d", workingDigit] atIndex:0]; 
} 

btw列是一個int,聲明爲一個實例變量。同樣,的NSLog打印出 「列(空)」

+1

'的NSLog(@ 「列%@」,列);' 應該是'的NSLog(@「列%d「,列);' – Hector

回答

2

你應該使用這樣的:

NSLog(@"column %d", column); 
+0

謝謝^^有趣,但是,如何改變列.. – Mirror318