-
Notifications
You must be signed in to change notification settings - Fork 25
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
Can't get it to work #3
Comments
I see several problems with this. When you all Client.sentProxy(String,String), there are a number of variants, but mostly, the first parameter is an Objective-C class name and the second argument is a message name, and subsequent arguments are parameters to the message. E.g. the call
Is the equivalent of calling There is no message Perhaps you are looking for Through the objective-c bridge this would be
You make similar errors throughout this code. What I sometimes do is write the code that I want (or close to it) in objective-c, then translate it into java using the objective-c bridge. That way it is easier to debug the process incrementally. |
Thanks for your comment 👍 I edited my code a bit and it's working but not completly ^^ Here the code: Client c = Client.getInstance();
Proxy nsPrintInfo = c.sendProxy("NSPrintInfo", "sharedPrintInfo");
nsPrintInfo.send("setTopMargin:", 0);
nsPrintInfo.send("setBottomMargin:", 0);
nsPrintInfo.send("setLeftMargin:", 0);
nsPrintInfo.send("setRightMargin:", 0);
nsPrintInfo.send("setHorizontalPagination:", "NSFitPagination");
nsPrintInfo.send("setVerticalPagination:", "NSFitPagination");
nsPrintInfo.send("setPaperSize:", "NSMakeSize(595.275591, 841.88976378)");
Proxy nsUrl = c.sendProxy("NSURL", "fileURLWithPath:", filename);
Proxy pdfDocument = c.sendProxy("PDFDocument", "initWithURL:", nsUrl);
Proxy nsPrintOperation = c.sendProxy("NSPrintOperation", "nsPrintOperation", pdfDocument); // this line is still wrong
nsPrintOperation.send("setShowsPrintPanel:", false);
nsPrintOperation.send("setShowsProgressPanel:", false);
boolean succeed = nsPrintOperation.sendBoolean("runOperation"); I know, that some nsPrintInfo calls are not right, but that's not the problem for now. My question is, how can I pass a created Object/Proxy as argument to another call/function like The obj-c code for creating a pdfdocument is:
PDFDocument is placed in sub-framework PDFKit in And another question. I found a line of code on stackoverflow: How can I get this to work? Something like: I hope you can help me again, thanks :) |
The Client.chain() method may allow you to do this all in one shot, but I'm out of practice and don't remember the exact semantics off the top of my head.
becomes
I think that is imported by default. But if you need to import a library, you can do that using the Native.loadLibrary method. See the example with webkit here: |
One other tip. Constants like NSFitPagination can't be passed as the string constant name. You'll need to find their values and pass them that way. E.g.
So Instead of
you would do
|
At first, thanks for answering :) Everytime on And I don't know how I can load a library/framework inside another one. Any idea? Thanks :) |
Native.loadLibrary("Quartz") gets PDFDocument for me. What happens when you do something like: Native.loadLibrary("Quartz", PDFKit.class); (Where PDFKit is just a dummy interface you created with no methods). On Sun, Nov 15, 2015 at 3:41 AM, Dominic Eubel notifications@github.com
Steve Hannah |
This means: Native.loadLibrary("Quartz");
Proxy pdfdocument = c.sendProxy("PDFDocument", "alloc"); should be enough to get PDFDocument? I need to test again at work on monday.
Do you mean like in WebKit example? : public static interface WebKit extends Library {
public final static TestWebView.WebKit INSTANCE = (TestWebView.WebKit)Native.loadLibrary("WebKit", TestWebView.WebKit.class);
} Could look like adapted: public static interface Quartz extends Library {
public final static TestClass.Quartz INSTANCE = (TestClass.Quartz)Native.loadLibrary("Quartz", TestClass.Quartz.class);
} and then |
On Sun, Nov 15, 2015 at 8:18 AM, Dominic Eubel notifications@github.com
Steve
Steve Hannah |
I updated my last comment :) Thanks 👍 Maybe you can post here a/your minimal code, with class, dummy interface and loadlibrary and pdfdocument alloc. So I only need to import it in my IDE and run it for testing. |
Here is a gist. I just used the WebView test and added some calls to instantiate a On Sun, Nov 15, 2015 at 8:25 AM, Dominic Eubel notifications@github.com
Steve Hannah |
Thank you so much :) Will test it tomorrow 👍 |
So, I have tested it, but it doesn't really work.
I get :
|
That crash doesn't look like it happens there. Do you do anything with the
|
It's not possible for me to work with it because it crashes directly after/with |
Please post test case. I can't reproduce. Works fine for me.
|
Mhhh, thats curious :/ |
I did a test again. I used your gist and found out:
but if I put the breakpoint in another method (like someFuncWithMultipleArgs) then it runs fine and no crash. Can you reproduce this case? |
Hey guys,
I need to work with some Objective-C classes from Java-8.
I'm working with MacOs10.11
If I try the sample (high level api) code, it works fine.
This is the code:
But if I try it with other classes, it doesn't work and my application is crashin with this error:
I need to work with NSPrintInfo, NSPrintOperation and PDFDocument.
That's my code:
I get the crash with
Proxy nsPrintInfo = c.sendProxy("NSPrintInfo", "printinfo");
I hope you can help me.
Thanks :)
The text was updated successfully, but these errors were encountered: