2012-06-26 44 views
0

我定义为这样的(如图schedule.h文件)类(附表)方法不可见

#import <UIKit/UIKit.h> 
#import "TdCalendarView.h" 
#import "AppDelegate.h" 

@interface Schedule : UIView { 
    IBOutlet UIView *schedule; 
} 

- (void) calendarTouched:(CFGregorianDate) selectedDate; 

@end 

Schedule.m看起来是这样的:

- (void) calendarTouched: (CFGregorianDate) selectedDate { 

    NSLog(@"calendarTouched - currentSelectDate: %@/%@/%@", selectedDate.month, selectedDate.day, selectedDate.year); 
    return; 
} 

在另一类,我打电话calendarTouched这个方法调用:

Schedule *sch = [[Schedule alloc] init]; 
[sch.calendarTouched:currentSelectDate]; 

我得到一个在Schedule类型的对象上找不到“calendarTouched”错误。 (我在调用类中有#import“Schedule.h”)

我已经做了一个干净的,但无济于事。为什么它找不到它?

回答

3

您不要在Objective-C中调用类似的方法。做到这一点,而不是:

[sch calendarTouched:currentSelectDate]; 
+0

我不敢相信!就在我面前,我知道得更多......非常感谢你...... – SpokaneDude

4
[sch.calendarTouched:currentSelectDate]; 

您在这里结合了点语法和括号语法。这应该是:

[sch calendarTouched:currentSelectDate]; 
+0

感谢约什..我打上DrummerB回答正确的,因为他是第一个... – SpokaneDude

+0

DrummerB的回答竟是29秒_after_矿,但我们得到的对号并不重要,我。 (无论如何,这是在“同一时间”的答案门槛内。) –