Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > awakeFromNib called twice?

awakeFromNib called twice?
Thread Tools
jessejlt
Mac Enthusiast
Join Date: Feb 2003
Location: Portland, Oregon
Status: Offline
Reply With Quote
Jul 24, 2004, 07:47 PM
 
I'm writing an OpenGL program in C++, but am using Objective-C++ / Cocoa for the GUI front-end. For some reason awakeFromNib, initWithFrame:, and initGL are all being called twice. awakeFromNib is responsible for calling a C++ function within one of my C++ back-end classes which creates a list of objects.... Now does this mean that I have two instances of this list? Is it normal for these functions to be executed twice? If not, any suggestions on how to fix it? I've done a little bit of searching and it seems to be a bi-product of NSDocument based programs, but this is just subclassed OpenGLView. So the header of my one and only Objective-C++ class is:
@interface MyOpenGLView : NSOpenGLView
Appreciate any help you can give me.
Jesse Thompson
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Jul 25, 2004, 11:35 AM
 
No, AFAIK, those methods should not be called twice unless there are two instances of the object.
[Wevah setPostCount:[Wevah postCount] + 1];
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jul 25, 2004, 10:12 PM
 
Put an NSLog(@"%@", self) in at the beginning of your awakeFromNib method to see if it's being called on the same instance.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
jessejlt  (op)
Mac Enthusiast
Join Date: Feb 2003
Location: Portland, Oregon
Status: Offline
Reply With Quote
Jul 25, 2004, 11:48 PM
 
Originally posted by Chuckit:
Put an NSLog(@"%@", self) in at the beginning of your awakeFromNib method to see if it's being called on the same instance.
I'm not sure what the output means:
2004-07-25 20:47:22.989 447Project[3010] <MyOpenGLView: 0x33c3do>
2004-07-25 20:47:23.058 447Project[3010] <MyOpenGLView: 0x344980>
     
Uncle Skeleton
Addicted to MacNN
Join Date: Nov 2002
Location: Rockville, MD
Status: Offline
Reply With Quote
Jul 26, 2004, 01:45 AM
 
it means there are two different instances of your view and each one gets awakeFromNib called on it once
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Jul 26, 2004, 07:17 PM
 
This implies that you're class is getting instantiated twice. Is it instantiated by the NIB itself? Is it also instantiated in code ( alloc, init)?
     
   
Thread Tools
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 03:13 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,