Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone SDK - instance variable out of scope issue
    text
    copied!<p>I am getting crazy over this error. Compiler is saying out of scope for an instance NSSString variable. Never had this thing before and used thousands of NSString instance variables!</p> <p>Here is my class .h file</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import &lt;AVFoundation/AVFoundation.h&gt; #import &lt;CoreAudio/CoreAudioTypes.h&gt; #import "Snapshot.h" @interface RecordAudioViewController : UIViewController &lt;AVAudioRecorderDelegate, AVAudioPlayerDelegate&gt; { NSString *filename; } @property (nonatomic, retain) NSString *filename; - (IBAction) recordAudio; - (IBAction) playAudio; @end </code></pre> <p>Variable is synthesized properly. I initalize filename variable in viewDidLoad method. I want to use it in IBAction method recordAudio, but compiler always says out of scope? Why is that, is this a bug or something?</p> <p>Here is .m code. viewDidLoad method where I set the filename instance variable:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; </code></pre> <p>NSString *tmpDir = NSTemporaryDirectory(); filename = [NSString stringWithFormat: @"%.0f.%@", [NSDate timeIntervalSinceReferenceDate] * 1000.0, @"caf"]; NSLog(filename); }</p> <p>And the IBAction method</p> <pre><code>- (IBAction) recordAudio { NSLog(filename); // here I get out of scope message when moving over with mouse cursor and when steping over this line EXC_BAD_ACCESS } </code></pre> <p>The entire .m file can be seen here: <a href="http://pastie.org/1021993" rel="nofollow noreferrer">http://pastie.org/1021993</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload