小编Big*_*ola的帖子

如何使用Interface Builder管理Cocoa应用程序中的多个窗口

我有3个类的应用程序:AppController,Profile,ProfileBuilder.我还需要3个窗口:每个班级一个.我尝试将所有3作为NSObject的子类并将initWithNibName应用于NSWindowController类WindowController变量但是当我尝试在每个窗口上输出一些值时它不起作用,并且使用NSLog将窗口生成为null.我想知道管理多个窗口的最佳方法是什么,可能所有来自同一个类,如AppWindowsController,尽可能少地涉及其他类中的特定代码,并且如果可能的话,保留其他类作为NSObject的子类而不是NSWindowController .因此,如果存在,可能是一种远程控制窗口行为的方法,在特定类中添加尽可能少的代码,只是为了使它们尽可能清晰并专注于其内容.谢谢,希望我明确表示,我实际上是Cocoa框架的新手.

xcode cocoa window nswindow

4
推荐指数
1
解决办法
2247
查看次数

从NSIntegers之间的划分中获取浮点数

我有两个名为"domande"和"corrette"的NSInteger变量.我必须用它们执行这个操作:corrette*10/domande.我希望结果是一个浮点变量,所以我声明了一个"voto"变量:"float voto = corrette*10/domande;" .当我用NSLog输出"voto"的值时,得到结果的近似值,后跟".000000".

这是代码:

NSInteger domande = [numDomande integerValue];
NSInteger corrette = [numRisposteCorrette integerValue];
float voto = corrette*10/domande;
NSLog(@"float value is: %f", voto);
Run Code Online (Sandbox Code Playgroud)

当我为"domande"赋值7时,并且"corrette"值为4:voto = 5.000000相反它应该是voto = 5.71 ...

如何让除法返回不是转换为float的整数类型,而是直接浮点类型?

floating-point objective-c nsinteger

2
推荐指数
2
解决办法
9889
查看次数

我正在使用"this"关键字和"call"方法传递一些元素

我要做的是将一个确定的元素传递给一个函数,我试图用"this"关键字表示.问题是它必须跨越两个函数,我不明白错误在哪里.一切都从第三个函数开始,然后调用第二个函数传递document.body,因为它将被视为函数的"this".然后第二个函数使用"call"方法将"this"传递给第一个函数.

function create_tag(tag, inner) {
    element = document.createElement(tag);
    if (inner) {
        element.innerHTML = inner;
    }
    this.appendChild(element);
    return element;
}

function create_input(label_value) {
    input = create_tag.call(this, "input");
    label = create_tag.call(this, "label", label_value);
    input.setAttribute("id", "pers_" + label_value);
    return input;
}

function crea_personaggio() {
    input_values = ["Name", "Lastname", "Nickname", "Age"];
    for (i = 0; i < input_values.length; i++) {
        create_input.call("document.body", input_values[i]);
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript this

0
推荐指数
1
解决办法
42
查看次数