• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: GLobal Variables and Object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GLobal Variables and Object


  • Subject: Re: GLobal Variables and Object
  • From: David Reed <email@hidden>
  • Date: Wed, 5 May 2004 12:10:43 -0400

Eli,

What is the easiest way to instiante an object (for example an NSmutableString)
such that is is visible to ALL functions and methods in a program
Make it a global variable, just like C.

How would I then destroy this object at
the end of my program?
Usually, you just don't. It'll get destroyed when your application exits along with the rest of your memory space.

How generrally does scope work in objective C? In regular C, if a variable is
defined in a function, it is only visible in that function. In objective C,
are objects created (say in a method of some object) global in scope?
Objective-C scoping is generally the same as C, because Objective-C *is* C with a Smalltalk-style object model.

Basically I have application data that I want accessibly to all of my window
controller objects and custom handling objects, etc. What is the safest way to
do this?
Probably global variables unless you are using threads, in which case you need extra safeguards.

I suggest reading Apple's online documentation on the Objective-C language. Most of your language questions would be answered therein.

David.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >GLobal Variables and Object (From: "Eli Hughes" <email@hidden>)

  • Prev by Date: Re: NSTextField and bindings
  • Next by Date: Re: Objective-C question
  • Previous by thread: GLobal Variables and Object
  • Next by thread: Re: GLobal Variables and Object
  • Index(es):
    • Date
    • Thread