【发布时间】:2013-11-18 15:57:02
【问题描述】:
在尝试使用 XCTest 测试我的应用程序时,执行以下操作时出现构建错误:
#import <XCTest/XCTest.h>
@interface MyTests : XCTestCase
@end
@implementation MyTests
- (void)testExample
{
NSString *str = @"foo";
XCTAssertTrue(YES, str); // Parse issue: Expected ')'
}
@end
但如果我这样做,我不会收到构建错误:
#import <XCTest/XCTest.h>
@interface MyTests : XCTestCase
@end
@implementation MyTests
- (void)testExample
{
XCTAssertTrue(YES, @"foo"); // this is just fine...
}
@end
我得到的构建错误是:
Parse issue: Expected ')'
它会在“str”中的“s”下方放置一个箭头。
我发现我可以通过改变来解决这个问题
XCTAssertTrue(YES, str)
到
XCTAssertTrue(YES, @"%@", str)
但我就是不知道为什么会有所作为。有人可以解释一下为什么会这样吗?
【问题讨论】:
标签: ios objective-c xcode macos xctest