incorrect variable value outside main()

Posted by cru3l on Stack Overflow See other posts from Stack Overflow or by cru3l
Published on 2010-04-05T21:58:44Z Indexed on 2010/04/05 22:03 UTC
Read the original article Hit count: 226

Filed under:
|

i have this code

#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;
}

in output i have:

5 (null)

why Test function doesn't see correct teststring value? What should I do, to have correct "test string" in output?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa