Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

igul222

macrumors newbie
Original poster
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.
 

Attachments

  • error.jpg
    error.jpg
    23.2 KB · Views: 185
Look in your books about local and global variables and variable scope. That should clear up your questions.
 
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:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.