I created a new function to log every method from a class in runtime.

The problem that I have is in this line :


id value = va_arg(stackFrame, id);


Doesn`t convert the type of object inside the arguments.


Any idea on what I'm doing wrong? Is there another way to do this?


   void InitDebug ( id self, SEL _cmd, ...)

{

 id receiver = self;

    SEL receiverSelector = _cmd;

 va_list stackFrame;

 va_start(stackFrame, _cmd);

 NSString* threadString = [NSString stringWithFormat:@"%@", [NSThread
currentThread]];

 NSMutableString* logString = [NSMutableString string];

 [logString appendString:[NSString stringWithFormat: @"After - Thread:%@ -
Class:%@ - Method:%@",

      threadString,

      NSStringFromClass([receiver class]),

      NSStringFromSelector(receiverSelector)]];

 NSMethodSignature *signature

    = [receiver methodSignatureForSelector:receiverSelector];



    NSUInteger count = [signature numberOfArguments];

 if (count == 2)

    {

 [logString appendString:[NSString stringWithFormat:@" None"]];

}

     NSUInteger index = 2;

     for (; index < count; index++)

    {

        const char *argType = [signature getArgumentTypeAtIndex:index];



        if ((strlen(argType) > 1)

 && (strchr("{^", argType[0]) == NULL)

 && (strcmp("@?", argType) != 0))

        {

            [NSException raise:NSInvalidArgumentException

                        format:@"Cannot handle argument type '%s'.",
argType];

        }

#define IS_EQUAL 0

        if (strcmp(argType, @encode(id)) == IS_EQUAL)

        {

            id value = va_arg(stackFrame, id);

            if (!value)

            {



            }

        }

    }

 NSLog(@"%@",logString);

 va_end(stackFrame);

 }


-- 
Guillermo Moral
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to