解决方法
这是一个好主意,为什么Class Extensions被设计(为什么它们与类别不同).
也就是说,你可以:
foo.h中
- @interface Foo:NSObject
- ...public API here...
- @property(readonly,copy) NSString *name;
- @end
Foo_FrameworkOnly.h
- @interface Foo()
- @property(readwrite,copy) NSString *name;
- @end
Foo.m
- #import "Foo.h"
- #import "Foo_FrameworkOnly.h"
- @interface Foo()
- ... truly implementation private gunk,including properties go here ...
- @end
- @implementation Foo
- @synthesize name = name_;
- @end