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

class keyword causes issues withIn the subclassed objective-c class #25

Closed jessepollak closed 9 years ago

jessepollak commented 9 years ago

I've been using OCMapper in Swift and I've run into a compilation problem. This may be an issue with XCode/Swift/Objective-C, but I figured I would open an issue here.

All was working well until I tried to subclass a custom Objective-C class that I had created (a subclass of UIViewController). When I tried to do this, I ran into a build error which pointed to OCMapper.

screenshot 2015-05-20 11 58 55 screenshot 2015-05-20 11 57 26

Not subclassing the custom Objective-C class makes the build error go away (even if I still do the import).

Any ideas?

aryaxt commented 9 years ago

What do you mean by this "Not subclassing the custom Objective-C class makes the build error go away"?

I'm using it in Swift myself, and I have many subclasses of objective-c classes with no issue. Does renaming the class parameter to something else fix the issue?

jessepollak commented 9 years ago

So, if I leave the import in my Module-Bridging-Header.h and instead of subclassing CustomViewController, I subclass UIViewController, the app builds. It's only when I subclass CustomViewController in my Swift code that the build fails.

Yes, I changed it to klass and the problem was resolved, but I'm using Cocoapods, so this isn't really viable.

Thank you so much for your help :)

aryaxt commented 9 years ago

That's really odd, will look into it and change that in the next version.

jessepollak commented 9 years ago

Thank you, I'm just holding out from subclassing in Swift for as long as possible :)

aryaxt commented 9 years ago

Just one more thing before I push a fix for this. Are you using Swift 1.2?

jessepollak commented 9 years ago

I have XCode 6.3.1, which comes with v1.2, so I'm pretty sure, yes.

aryaxt commented 9 years ago

Can you check if this commit fixes the issue for you?

pod 'OCMapper', :git => 'https://github.com/aryaxt/OCMapper.git', :commit => '8a26f84537b803c1502963cb4e238195213ec8b3'

jessepollak commented 9 years ago

This does indeed fix the issue — sorry about the delay!

aryaxt commented 9 years ago

Cool, will push this to cocoapods tonight

jessepollak commented 9 years ago

Awesome, thank you!

On Mon, Jun 1, 2015 at 12:05 PM, Aryan Ghassemi notifications@github.com wrote:

Cool, will push this to cocoapods tonight

— Reply to this email directly or view it on GitHub https://github.com/aryaxt/OCMapper/issues/25#issuecomment-107672965.

edwardvalentini commented 9 years ago

+1 i have the same issue :)