我有这个代码
#import <Foundation/Foundation.h>
int testint;
NSString *teststring;
int Test()
{
NSLog(@"%d",testint);
NSLog(@"%@",teststring);
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
testint = 5;
NSString *teststring = [[NSString alloc] initWithString:@"test string"];
Test();
[pool drain];
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在输出我有:
5(null)
为什么Test函数没有看到正确的teststring值?我应该怎么做,在输出中有正确的"测试字符串"?