Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source Tool For Automatically Graphing Objective-C Class/Instance Details

  •  
  •  
  •  
  •  
  •  

Just over a year ago I mentioned an open source tool that allows you to create class dependency graphs from your Objective-C code viewable in GraphViz.

Here’s another Objective-C graphing tool called ObjcViz originally created by Oliver Gutknecht and updated by Graham Lee to run with the new Obj-C runtime.

This tool  allows you to gather detailed information about the classes and instances running in a program and creates code that you can load into GraphViz.

Here’s an example from the home page – you can take code like this:

@interface Bu : NSObject
{
   NSString* superclassIvar;
}
@end

@interface Meu : NSObject
{
   id obj;
}
@end

@implementation Meu

-(id)init
{
   [super init];
   obj = @"hello";
   return self;
}

@end


@interface Zo : Bu
{
   NSString* d;
   id e;
}
@end

@implementation Zo

-(id)init
{
   [super init];
   e = [NSScanner
     scannerWithString:@"scannedString"]
   [e retain];
   return self;
}

@end

@interface Ga : NSObject
{
   NSString* strIvar;
   NSMutableArray* arrayIvar;
   NSMutableDictionary* dictIvar;
   Zo* boIvar;
}
@end

@implementation Ga

-(id)init
{
   [super init];
   strIvar = @"aString";
   boIvar = [[Zo alloc] init];
   arrayIvar = [[NSArray alloc]
     initWithObjects:@"aStringInArray",
                    [NSDate date], nil];
   dictIvar = [[NSMutableDictionary alloc]
    initWithObjectsAndKeys:boIvar,@"Key1",@"Obj2",@"Key2",nil];
   return self;
}

@end

And get the GraphViz code to generate a graph like this:

OCV

You can find the updated ObjcViz project on Github here.

You can find the homepage for the original project here.

You can find the open source GraphViz tool here.

A great way to visualize what’s happening in your code.. especially great if you’re looking at someone else’s project.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments