本文整理汇总了Java中com.apple.jobjc.foundation.NSString类的典型用法代码示例。如果您正苦于以下问题:Java NSString类的具体用法?Java NSString怎么用?Java NSString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSString类属于com.apple.jobjc.foundation包,在下文中一共展示了NSString类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAppKit_NSString
import com.apple.jobjc.foundation.NSString; //导入依赖的package包/类
public void testAppKit_NSString(){
AppKitFramework APPKIT = JObjC.getInstance().AppKit();
NSString nstr = Utils.get().strings().nsString("mirzapirza");
NSStringCategory nstrx = APPKIT.NSStringCategory(nstr);
NSSize sz = nstrx.sizeWithAttributes(null);
assertEquals(57.0, sz.width());
assertEquals(15.0, sz.height());
}
示例2: mainWithoutAppMain
import com.apple.jobjc.foundation.NSString; //导入依赖的package包/类
public static void mainWithoutAppMain(String[] args){
Toolkit.getDefaultToolkit();
Utils.get().threads().performOnMainThread(new Runnable(){
public void run() {
APPKIT.NSApplication().sharedApplication();
NSApplication APP = APPKIT.NSApp();
NSString nibName = Utils.get().strings().nsString("MainMenu");
boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP);
if(!loadedNib) throw new RuntimeException("Failed to load nib.");
}}, false);
}
示例3: testNSString_initWithFormat
import com.apple.jobjc.foundation.NSString; //导入依赖的package包/类
public void testNSString_initWithFormat(){
String expected = "1 + 0.2 = 1.2 abracadabra";
NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@");
NSString abra = Utils.get().strings().nsString("abracadabra");
NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra);
String actual = Utils.get().strings().javaString(nstr);
assertEquals(expected, actual);
}
示例4: testNSDictionary
import com.apple.jobjc.foundation.NSString; //导入依赖的package包/类
public void testNSDictionary(){
NSString v1 = Utils.get().strings().nsString("value1");
NSString v2 = Utils.get().strings().nsString("value2");
NSString k1 = Utils.get().strings().nsString("key1");
NSString k2 = Utils.get().strings().nsString("key2");
NSDictionary dict = ((NSDictionary)FND.NSDictionary().alloc()).initWithObjectsAndKeys(v1, k1, v2, k2, null);
NSString nsdescr = dict.description();
String jdescr = Utils.get().strings().javaString(nsdescr);
assertEquals("{\n key1 = value1;\n key2 = value2;\n}", jdescr);
}
示例5: testNSStringNSStringMethod
import com.apple.jobjc.foundation.NSString; //导入依赖的package包/类
public void testNSStringNSStringMethod(){
final MyObject instObj = new MyObjectClass(runtime).alloc();
final NSString orig = Utils.get().strings().nsString("foobar");
final String expected = "foobarfoobarfoobar";
final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
sel.init(ctx, instObj);
IDCoder.INST.push(ctx, orig);
sel.invoke(ctx);
NSString ret = (NSString) IDCoder.INST.pop(ctx);
assertEquals(expected, Utils.get().strings().javaString(ret));
}
示例6: stringTimesThree
import com.apple.jobjc.foundation.NSString; //导入依赖的package包/类
public NSString stringTimesThree(NSString nss){
int count = 3;
String jss = Utils.get().strings().javaString(nss);
String js2 = "";
while(count-- > 0)
js2 += jss;
return Utils.get().strings().nsString(js2);
}
示例7: testNSClassName
import com.apple.jobjc.foundation.NSString; //导入依赖的package包/类
public void testNSClassName(){
NSString s = ((NSString) FND.NSString().alloc()).init();
NSString cname = s.className();
String jcname = Utils.get().strings().javaString(cname);
assertEquals("NSCFString", jcname);
}
示例8: testNSClassPop
import com.apple.jobjc.foundation.NSString; //导入依赖的package包/类
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);
}