Objective-C NSString Assignment Problem
        Posted  
        
            by golfromeo
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by golfromeo
        
        
        
        Published on 2010-06-05T20:40:34Z
        Indexed on 
            2010/06/05
            20:42 UTC
        
        
        Read the original article
        Hit count: 264
        
objective-c
|cocoa
In my Cocoa application, in the header file, I declare a NSString ivar:
NSString *gSdkPath;
Then, in awakeFromNib, I assign it to a value:
gSdkPath = @"hello";
Later, it's value is changed in the code:
gSdkPath = [NSString stringWithString:[folderNames objectAtIndex:0]];
(the object returned from objectAtIndex is an NSString)
However, after this point, in another method when I try to NSLog() (or do anything with) the gSdkPath variable, the app crashes. I'm sure this has something to do with memory management, but I'm beginning with Cocoa and not sure exactly how this all works.
Thanks for any help in advance.
© Stack Overflow or respective owner