🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
2 messages
2 total messages Started by Vikram Duvvoori Tue, 28 Jul 1992 05:39
Getting ids of Outlets of an object
#274
Author: Vikram Duvvoori
Date: Tue, 28 Jul 1992 05:39
33 lines
2064 bytes
Hi, 
	We are interested in developing some general tools that can  
dynamically access the various outlets of instances of other objects at  
run-time.
	For example, let Object1 have outlets a, b, c that are tagged 1, 2,  
and 3 and Object2 have outlets d,e that are tagged 4, 5. Given instances of  
Object1 and Object2 at run-time, what support is available in objective-C or  
Appkit, to determine the tags for the outlets of the instance variables. Are  
there any methods that give you information on the instance variables and list  
of methods for an object?
	We have attempted approaches using programmer stored lists of outlets  
(have a list of outlet names "a","b","c" for Object1 and "d","e" for Object2  
and process these lists for accessing tags). This has the problem of  
maintaining the correctness of these lists. Is there any smarter way of doing  
this? We  could probably parse the .h file for getting static information, but  
how about dynamically loaded objects? 

We have already searched through Digital Librarian and archives of CSNP.
Any ideas or pointers are welcome.

--Vikram
____________________________________________________________
Vikram Duvvoori                    vikram@viman.com
Viman Software                     800-827-4590 (Toll Free)
Registered NeXT Developers         408-459-0678  
NeXT Mail preferred                408-458-2862 (Fax)

-- 
____________________________________________________________
Vikram Duvvoori                    vikram@viman.com
Viman Software                     800-827-4590 (Toll Free)
Registered NeXT Developers         408-459-0678  
Re: Getting ids of Outlets of an object
#291
Author: Marcel Weiher
Date: Tue, 28 Jul 1992 17:41
68 lines
1954 bytes
vikram@viman.com  (Vikram Duvvoori) writes:


>Hi, 
>	We are interested in developing some general tools that can  
>dynamically access the various outlets of instances of other objects at  
>run-time.
[...]
>Appkit, to determine the tags for the outlets of the instance variables. Are  
>there any methods that give you information on the instance variables and list  
>of methods for an object?

One of the neat things about Objective-C is that it is so dynamic, and yes
it even retains structure information at runtime.

Look in the include file <objc/objc-class.h>, with a little
code to illustrate:

------------------------snip----------------------------
mport <objc/Object.h>
#import <objc/objc-class.h>

@interface Hi : Object
{
	int hi1;
	int hi2;
}

@end

@implementation Hi

-printIVars
{
	Hi*   s1=self;
	struct objc_ivar_list  *iv=s1->isa->ivars;
	struct objc_ivar *p1;
	int i;

	p1=&iv->ivar_list;
	for (i=0; i< iv->ivar_count ; i++ )
	{
		printf( "name= %s, type=%s, offset=%d\n",p1->ivar_name,p1->ivar_type,p1->ivar_offset);
		p1++;
	}
}


main()
{
	id hi=[Hi new];
	[hi printIVars];
}


@end

--------------------------snip----------------------

This produces the following output on my system:

marcel@spock[benchmarks]ivar
name= hi1, type=i, offset=4
name= hi2, type=i, offset=8
marcel@spock[benchmarks]


Marcel
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads