Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Generics in NSManagedObject Extension #45

Open
PGLongo opened this issue Oct 23, 2015 · 2 comments
Open

Use Generics in NSManagedObject Extension #45

PGLongo opened this issue Oct 23, 2015 · 2 comments

Comments

@PGLongo
Copy link
Collaborator

PGLongo commented Oct 23, 2015

I think that we could change NSManagedObject extension using generics.

For example:

Now

func createNewEntity(context:) -> NSManagedObject {}
...
let pokemon = Pokemon.createNewEntity() as! Pokemon

After

class func createNewEntity <T> (context:) ->  T {}
...
let pokemon : Pokemon = Pokemon.createNewEntity()

In my opinion is more secure because you receive a compile error if the type is not explicit!

@michaelarmstrong
Copy link
Owner

but still requires a type annotation right?

whats the interop with Obj-C like? id ?

@PGLongo
Copy link
Collaborator Author

PGLongo commented Oct 23, 2015

Obj-c with Xcode 7 has Generics, but I have never tried

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants