I’m working on an Obj-C app that got started a bunch of years ago and thought 
that I would start migrating some of the smaller pieces over to Swift.

Some existing Obj-C methods are of the form:

        + (nullable __kindof NSManagedObject) someFooThing;

Right now I have

        class var someFooThing: NSManagedObject?

but that generates a bunch of warnings saying there are incompatible pointer 
type, so Obj-C callers will need to cast the result to the specific subclass 
type:

        SonOfFoo sonOfFoo = (SonOfFoo)SonOfFoo.someFooThing;

which was what the original method handled automagically.

I tried the generics route but Xcode complains because it will be used in 
Obj-C. Obviously I can just go through and cast to clean up the warnings, but 
if there’s a nicer solution then I’d rather go that route.

I’ve been searching around this afternoon trying to see if anyone else has run 
across this. I haven’t found anything yet, but I don’t know if that’s due to 
poor search terms, or because someone more experienced with the process would 
say, “well, of course you can’t do that”. Any help?

Thanks,
Steve

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to