image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
LinkBack Thread Tools
  #1  
Old June 17th, 2002, 07:46 PM
Registered User
 
Join Date: Nov 2000
Posts: 948
Thanks: 0
Thanked 0 Times in 0 Posts
kainjow is on a distinguished road
Accessing objects from another class

OK, I've got a text field that's defined and used in one class, but I want the app's class to access this for putting the user defaults data into it. But, I can't get it to work. I thought importing the the class into the app's class would do it, but it won't work. Any suggestions?

Thanks.

(I have one window with different NSViews that each have their own contentView and each NSView has it's own class controller. I want the application's main class to access the text field that is controlled by another class)
Reply With Quote
  #2  
Old June 18th, 2002, 08:31 PM
ECE Student
 
Join Date: Mar 2001
Location: University of Arizona
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
macxonly is on a distinguished road
Lightbulb Hmmm

You must first instantiate the class that you are trying to use. In java, you instantiate the class to pass it arguments. You need to have a constructor, accessor, and mutator for the class you want to instantiate. Then you can access the objects in the class you want to use.

Did I make any sense...?

P.S. Been a while since I programmed so take my advice with a grain of salt.
Reply With Quote
  #3  
Old June 19th, 2002, 10:08 AM
Registered User
 
Join Date: Oct 2000
Location: U of I @ Champaign
Posts: 208
Thanks: 0
Thanked 0 Times in 0 Posts
Ghoser777 is on a distinguished road
There's a couple of ways to do this. You could have your class containing the text field to call a method off the other class that where one of the parameters is the text field object. You could also add a method to the your class containing the text field that returns the text field reference (if your app class has a reference to your other class. Additionally, if you instantiate both your classes in IB, you can just have the same text field be outlets for the different classes. Alos, you could use the notification center if you want and have the app class "listen" for the posting of a notification with your specified name and containing the text field.

Just keeping your options open (I think IB is the way to go, personally)
F-bacher
__________________
James Tiberius Kirk : "Spock,
the women are your planet are
logical. No other planet in the
universe can make that claim."
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling class methods FoolyCooly Software Programming & Web Scripting 2 October 23rd, 2003 06:47 PM
String class for g++ under OSX? Kinniken Software Programming & Web Scripting 5 October 7th, 2003 01:12 AM
SHUTDOWN without warning SCARY!! astro_sk Mac OS X System & Mac Software 10 May 16th, 2003 02:45 PM
X11 - Visual Class sjsadler Unix & X11 0 January 9th, 2003 10:26 AM
accessing menus in apple script mschmidt Software Programming & Web Scripting 0 March 19th, 2002 07:38 PM


All times are GMT -5. The time now is 10:54 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.