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.

DeliciousTwitterFacebookRedditLinkedInEmail

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

©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *