NSSet 看起来像一个协议 (NSSet<NSObject *> *name)
NSSet with what looks like a protocol (NSSet<NSObject *> *name)
我使用数据模型编辑器生成了 NSManagedObject
个子类(Photographer
和 Photo
)——它们有一个 Photographer
->To-Many-> Photo
关系。
Photographer
(CoreDataProperties) 类别带有 属性:
@interface Photographer (CoreDataProperties)
...
@property (nullable, nonatomic, retain) NSSet<Photo *> *photos;
@end
NSSet<Photo*>
是什么意思?您可以使用类似协议的表示法指定 NSSet
中应该包含什么类型的对象吗?在文档或其他任何地方都找不到有关它的任何信息。
这是最近为 Swift/Objective-C 互操作添加的。
请参阅:https://developer.apple.com/library/prerelease/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_7_0.html 并查找 "generics"。
在Xcode7 中,Apple 已将'Lightweight Generics'添加到Objective C。
如果存在类型不匹配,它们将生成编译器警告。
Objective-C declarations of NSArray, NSSet and NSDictionary types
using lightweight generic parameterization are imported by Swift with
information about the type of their contents preserved.
我使用数据模型编辑器生成了 NSManagedObject
个子类(Photographer
和 Photo
)——它们有一个 Photographer
->To-Many-> Photo
关系。
Photographer
(CoreDataProperties) 类别带有 属性:
@interface Photographer (CoreDataProperties)
...
@property (nullable, nonatomic, retain) NSSet<Photo *> *photos;
@end
NSSet<Photo*>
是什么意思?您可以使用类似协议的表示法指定 NSSet
中应该包含什么类型的对象吗?在文档或其他任何地方都找不到有关它的任何信息。
这是最近为 Swift/Objective-C 互操作添加的。
请参阅:https://developer.apple.com/library/prerelease/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_7_0.html 并查找 "generics"。
在Xcode7 中,Apple 已将'Lightweight Generics'添加到Objective C。
如果存在类型不匹配,它们将生成编译器警告。
Objective-C declarations of NSArray, NSSet and NSDictionary types using lightweight generic parameterization are imported by Swift with information about the type of their contents preserved.