Undeclared Array...

Discussion in 'Mac Programming' started by igul222, Nov 6, 2007.

  1. macrumors newbie

    Joined:
    Nov 6, 2007
    #1
    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.
     

    Attached Files:

  2. Moderator emeritus

    SilentPanda

    Joined:
    Oct 8, 2002
    Location:
    The Bamboo Forest
    #2
    Look in your books about local and global variables and variable scope. That should clear up your questions.
     
  3. macrumors 6502

    hankolerd

    Joined:
    Sep 19, 2007
    Location:
    Seattle, WA
    #3
    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:
     

Share This Page