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

Implicitly convert Pointer to id #30

Closed
vakrilov opened this issue Mar 16, 2015 · 1 comment
Closed

Implicitly convert Pointer to id #30

vakrilov opened this issue Mar 16, 2015 · 1 comment

Comments

@vakrilov
Copy link

Think about implicitly converting pointer to ids. This will make the following code easier to translate to NativeScript:

CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], (id)[[UIColor blackColor] CGColor], nil];

Currently, this looks like this on NS:

var gradient = CAGradientLayer.layer();
var colorsArray = NSMutableArray.alloc().initWithCapacity(2);
colorsArray.addObject(interop.types.id(UIColor.redColor().CGColor));
colorsArray.addObject(interop.types.id(UIColor.blueColor().CGColor));
gradient.colors = colorsArray;

If there is implicit convertion - we can get rid of the interop.types.id( ... ) calls

@jasssonpet
Copy link
Contributor

This can now be done simply as:

var gradient = CAGradientLayer.layer();
gradient.colors = [UIColor.redColor().CGColor, UIColor.blueColor().CGColor];

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

No branches or pull requests

2 participants