aryaxt / OCMapper

Objective-C library to easily map NSDictionary to model objects, works perfectly with Alamofire. ObjectMapper works similar to GSON
MIT License
347 stars 45 forks source link

ManagedObjectInstanceProvider.emptyInstanceForClass() issue with Swift #17

Closed hopiaw closed 9 years ago

hopiaw commented 9 years ago

Hi,

I reach the point where one of my swift class is calling the following:

self.mapper.objectFromSource(JSON, toInstanceOfClass:MySwiftClass.self)

In the method of class ManagedObjectInstanceProvider:

- (id)emptyInstanceForClass:(Class)class

the call to:

[NSEntityDescription entityForName:NSStringFromClass(class)  inManagedObjectContext:self.managedObjectContext];

will always return nil cause the result of NSStringFromClass(class) will be something like:

"ProjectName.ClassName"

In Objective C, the above method will return an entityDescription if the entityForName parameter is "ClassName".

Do you have an idea on how I can make that call working?

Thanks.

hopiaw commented 9 years ago

My bad, I miss that @objc declaration in my class.

aryaxt commented 9 years ago

Cool Will add some Swift tests/samples to the project soon