本文整理汇总了Java中com.apple.jobjc.foundation.NSString.description方法的典型用法代码示例。如果您正苦于以下问题:Java NSString.description方法的具体用法?Java NSString.description怎么用?Java NSString.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.apple.jobjc.foundation.NSString
的用法示例。
在下文中一共展示了NSString.description方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFrameworks
import com.apple.jobjc.foundation.NSString; //导入方法依赖的package包/类
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();
}