다른 클래스를 호출 할 때 'AppDelegate에'에 대한 눈에 띄는 @interface : 나는 기본적으로 오전나는이 같은 사용자 정의 클래스의 구현이
...
@implementation AppDelegate
...
-(void)createLabel{
MyNotificationView *view = [[MyNotificationView alloc] initWithFrame:CGRectMake(0,0,100,100)];
view.theid = notification_id;
}
-(void)markAsRead:(int)index{
NSMutableArray *arrayofdics = [[[NSUserDefaults standardUserDefaults] objectForKey:@"arrayofdics"] mutableCopy];
NSMutableDictionary *dic = [[arrayofdics objectAtIndex:index] mutableCopy];
[dic setObject:[NSNumber numberWithBool:1] forKey:@"read"];
[arrayofdics replaceObjectAtIndex:index withObject:dic];
[[NSUserDefaults standardUserDefaults] setObject:arrayofdics forKey:@"arrayofdics"];
[self createBodyWindow];
unreadNotifications--;
[self setNotificationMenuBar];
}
...
: 다음
@interface MyNotificationView: NSView
@property (nonatomic) int theid;
@end
@implementation MyNotificationView
- (void) rightMouseDown:(NSEvent *)event {
[self markread];
}
- (void)markread {
//call markAsRead in AppDelegate with _theid as param
}
@end
그리고 나는 내 AppDelegate에이 없습니다 NSView
에 오른쪽 클릭의 기능을 추가하려고 시도하므로 오른쪽 클릭 할 때 AppDelegate
클래스 내에있는 메소드가 실행되지만 작동하지 않습니다.
나는 추가 시도 :
@property (nonatomic) AppDelegate* thisapp;
의 @interface
MyNotificationView
에. 다음 AppDelegate
들에있어서 추가 createLabel
: 다음
view.thisapp = self;
와 같은 MyNotificationView
S markAsRead
방법 일 무언가 :
[markAsRead _thisapp : _theid]; 내가 제대로이를 구현하는 방법을
No visible @interface for 'AppDelegate' declares the selector 'markAsRead:'
:
하지만이 오류가 발생합니다.