I'm working on an ios application that has a mix of swift and obj-c code. One of my obj-c model classes defines a struct containing strings to assist in converting to a dictionary and back. I have the bridging header setup and I can access methods defined in my objective-c class in a swift class. What I can't figure out is how to access the static stuct to get at my property strings. Here is a snippet of my .h and .m files:
OrderItem.h
extern const struct OrderItemAttributes {
__unsafe_unretained NSString *created;
__unsafe_unretained NSString *created_by_id;
__unsafe_unretained NSString *device_deleted;
} OrderItemAttributes;
@interface OrderItem : NSManagedObject {}
@property (nonatomic, strong) NSDate* created;
@end
OrderItem.m
const struct OrderItemAttributes OrderItemAttributes = {
.created = @"created",
.created_by_id = @"created_by_id",
.device_deleted = @"device_deleted",
};
@implementation OrderItem
@dynamic created;
@end
I thought I would simply be able to use
OrderItem.OrderItemAttributes.created
to access the attribute strings but swift doesn't accept that syntax. Is there any way to do what I want without major changes to my objective-c code?