Tôi chỉ đang học Cocoa (đến từ C#) và tôi nhận được một lỗi lạ cho một cái gì đó có vẻ thực sự đơn giản. (charsSinceLastUpdate >= 36
)So sánh giữa con trỏ và số nguyên
#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
Mọi trợ giúp sẽ được đánh giá cao, cảm ơn!
Cảm ơn, tôi nghĩ rằng * chỉ là một quy ước đặt tên phổ biến –