大家,我是 Stack Overflow(和 DDMathParser)的新手,但是因为当我尝试在 Objective-C++ 文件(main.mm)中使用 DDMathParser 时发生了一个奇怪的问题而来到这里。不管代码多么简单,它都会给出一个线程错误。这是我的代码:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <iostream>
#import "DDMathParser.h"
#import "NSString+DDMathParsing.h"
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
int main(int argc, char * argv[])
{
NSLog(@"%@", [@"5 + 5" numberByEvaluatingString]);
}
这是运行后的控制台:
2015-08-29 09:23:09.788 calculator[6212:101522] -[__NSCFConstantString numberByEvaluatingString]: unrecognized selector sent to instance 0x100001060
2015-08-29 09:23:09.792 calculator[6212:101522] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString numberByEvaluatingString]: unrecognized selector sent to instance 0x100001060'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff9365d03c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8fddd76e objc_exception_throw + 43
2 CoreFoundation 0x00007fff936600ad - [NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff935a5e24 ___forwarding___ + 1028
4 CoreFoundation 0x00007fff935a5998 _CF_forwarding_prep_0 + 120
5 calculator 0x0000000100000e86 main + 38
6 libdyld.dylib 0x00007fff864595c9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
有什么建议么?