在ox xCode(4.3)的最后一个版本中,我看到了在.m文件中进行接口声明的预定义模板(例如Master/Detail模板)。例如,文件中MyFile.h有:在实现文件中声明接口(Objective-C)
@interface MyFile
@property (nonatomic, retain) NSString *someProp;
@end
而在MyFile.m文件有:
@implementation MyFile
@interface MyFile {
NSString * anotherProp;
}
- (id) init...
为什么对这样做?为什么anotherProp未被声明为MyFile.h文件?
在此先感谢
这不是它看起来像,因为这是无效的代码。这可能是这样的:'@interface MyFile(){NSString * anotherPropt} @end @implementation MyFile - (id)init {...',在这种情况下请参阅:http://stackoverflow.com/questions/9751057/what- m-files-used-for-in-ios-5- –
你是对的,我从内存中发布它,我忘记了括号 – rai212