Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ NSObject性能选择器问题_C++_Objective C_Multithreading_Memory Management_Core Data - Fatal编程技术网

C++ NSObject性能选择器问题

C++ NSObject性能选择器问题,c++,objective-c,multithreading,memory-management,core-data,C++,Objective C,Multithreading,Memory Management,Core Data,这是另一个“我只是不知道发生了什么”的问题: 第一次调用下面的getFullWL(),我得到了预期的所有值。但是,每个后续调用都会返回nan,而不是真正的值(-nan(0x400000000)在XCode或其他什么东西中) 此外,如果我将我的“debug”行放入SFLog中,则值打印为nan,但返回正确的值!如果我注释掉SFLog(这只是根据我设置的级别定义的NSLog,没有什么特别之处),那么视图中的isnan()不会捕获该值,而是在窗口中选中为isnan() Window和View位于一个线

这是另一个“我只是不知道发生了什么”的问题:

第一次调用下面的
getFullWL()
,我得到了预期的所有值。但是,每个后续调用都会返回
nan
,而不是真正的值(
-nan(0x400000000)
在XCode或其他什么东西中)

此外,如果我将我的“debug”行放入
SFLog
中,则值打印为
nan
,但返回正确的值!如果我注释掉
SFLog
(这只是根据我设置的级别定义的
NSLog
,没有什么特别之处),那么
视图中的
isnan()
不会捕获该值,而是在
窗口中选中为
isnan()

Window
View
位于一个线程上,而
DataModule
DCMPix
位于另一个线程上(我相信是主线程)
DCMPix
还从核心数据对象获取一些数据(
fImage
我相信)


经过更多测试后,如果NSLog()语句出现在分配
float fullwl=
之前,那么我将它放在哪里并不重要

void Window::PopUp()
{
    // Grab the View from the Pipe Thread and cast it to my local namespace subclass View
    View *view = static_cast< View* >(getPipe()->getView(event.context.view));

    float fullww = view->getFullWW();
    NSLog("Putting this here, makes fullwl work.  Removing it, stores fullwl as nan");
    float fullwl = view->getFullWL();
    //SFLog(@"WindowLevel Window %f", wl);
void Window::PopUp()
{
//从管道线程获取视图,并将其转换为本地命名空间子类视图
View*View=static_cast(getPipe()->getView(event.context.View));
float fullww=view->getFullWW();
NSLog(“将其放在这里,使fullwl工作。删除它,将fullwl存储为nan”);
float fullwl=view->getFullWL();
//SFLog(@“窗口级窗口%f”,wl);

小崽子,我在这里再次回答我自己的问题,但答案是

aSelector参数应该标识一个不带参数的方法。对于返回对象以外的任何内容的方法,请使用

因此,答案是,使用
NSInvocation
而不是
[obj performSelector://code>

float View::getFullWL()
{
    float wl = _callPixMethod(@selector(fullwl)).floatValue;
    if ( isnan(wl) ) wl = _wl * 2.0f; //<-- is never detected as NaN here
    NSLog(@"WindowLevel View %f", wl);  //<-- is *printed* as NaN here
    return wl; //<-- returns expected value
}

float View::getFullWL()
{
    float wl = _callPixMethod(@selector(fullwl)).floatValue;
    if ( isnan(wl) ) wl = _wl * 2.0f; //<-- is never detected as NaN here
    return wl; //<-- returns `nan`
}
void Window::PopUp()
{
    // Grab the View from the Pipe Thread and cast it to my local namespace subclass View
    View *view = static_cast< View* >(getPipe()->getView(event.context.view));

    float fullww = view->getFullWW();
    NSLog("Putting this here, makes fullwl work.  Removing it, stores fullwl as nan");
    float fullwl = view->getFullWL();
    //SFLog(@"WindowLevel Window %f", wl);