Java源码示例:com.apple.jobjc.foundation.NSStringClass

示例1
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例2
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例3
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例4
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例5
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例6
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例7
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例8
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例9
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例10
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例11
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例12
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
示例13
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例14
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例15
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例16
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例17
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例18
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例19
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例20
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例21
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例22
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例23
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
示例24
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }