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