PDA

View Full Version : Undeclared Array...




igul222
Nov 6, 2007, 10:42 AM
Hi. I'm new to Objective-C, and programming in general (I've been writing code for all of 6 days), and I noticed that an array or string created in one method or function is unavailable to me in another:

I'm not really surprised (from what I know, this is to be expected), but I'm still wondering how to get around the problem.



SilentPanda
Nov 6, 2007, 10:45 AM
Look in your books about local and global variables and variable scope. That should clear up your questions.

hankolerd
Nov 6, 2007, 11:30 AM
yeah, read up on it and see what you find.
essentially what it comes down to, is if you declare a variable inside a class and outside of functions, it can be used in any function in that class, if you declare a variable inside a function, it can be used anywhere in that function, and that function only(unless passed to a different function):apple: