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

Methods being called on native objects as Objective-C functions, not the haxe versions #6

Open
zeen opened this issue Jul 1, 2013 · 2 comments

Comments

@zeen
Copy link

zeen commented Jul 1, 2013

@:keep private function test(s :Array<String>) {
    var i = s.length;
    var j = s.join(" ");
    var k = "hello";
    var l = k.length;
}

compiles to

- (void) test:(NSMutableArray*)s{

    int i = s.length;

    NSString *j = [s join:@" "];

    NSString *k = @"hello";
    int l = k.length;
}

This crashes, because length property and the join: selector don't exist in NSMutableArray, and length doesn't exist on NSString either, they should have been replaced with the Haxe code in Array.hx and String.hx.

@cristibaluta
Copy link
Owner

Is the Array.h is imported in your code? It's a category for NSMutableArray and i implemented those methods. For String indeed is not.

@zeen
Copy link
Author

zeen commented Jul 2, 2013

Ah, I figured out the cause of the array crash. You are right that Array.h should work. It fails in some cases where you cast NSArray into NSMutableArray, e.g., String.split uses componentsSeparatedByString, which returns an NSArray, so it doesn't have a length property. I'm fixing String.split to convert the NSArray into an NSMutableArray, will send a pull request.

Strings still need fixing.

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