7
我剛剛學習Cocoa(來自C#),並且對於看起來非常簡單的事情我收到了一個奇怪的錯誤。 (charsSinceLastUpdate >= 36
)指針和整數之間的比較
#import "CSMainController.h"
@implementation CSMainController
//global vars
int *charsSinceLastUpdate = 0;
NSString *myString = @"Hello world";
//
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
...
}
//other functions
- (void)textDidChange:(NSNotification *)aNotification {
NSLog(@"charsSinceLastUpdate=%i",charsSinceLastUpdate);
if (charsSinceLastUpdate>=36) { // <- THIS line returns the error: Comparison between pointer and integer
charsSinceLastUpdate=0;
[statusText setStringValue:@"Will save now!"];
} else {
charsSinceLastUpdate++;
[statusText setStringValue:@"Not saving"];
}
}
//my functions
- (void)showNetworkErrorAlert:(BOOL)showContinueWithoutSavingOption {
...
}
//
@end
任何幫助將不勝感激,謝謝!
謝謝,我以爲*只是一個常見的命名約定 – 2010-06-13 08:06:10