On Wed, Aug 21, 2013 at 4:22 AM, Dave <d...@looktowindward.com> wrote:

>         if ([myType isEqualToString:@"NSInteger"] )
>                 {
>                 myNSInteger = va_arg(myArgumentList,NSInteger*);
> //  do something with myNSInteger
>                 [myFormattedString appendFormat:@"myNSInteger = %d ",
> myNSInteger];
>                 }
>
>         else if ([myType isEqualToString:@"CGFloat"] )
>                 {
>                 myCGFloat = va_arg(myArgumentList, CGFloat*);
> //  do something with myCGFloat
>                 [myFormattedString appendFormat:@"myCGFloat = %f ",
> myCGFloat];
>                 }


This is better, however... if you pass an actual NSInteger or CGFloat to
the method, va_arg() should have a type of NSInteger or CGFloat, not
pointers to those types. Your code examples with it's printf style formats
is using the former, not the latter. Just to be clear, you can have all
these cases:

if ([myType isEqualToString:@"NSInteger"] ) {
   myNSInteger = va_arg(myArgumentList,NSInteger);
} else if ([myType isEqualToString:@"NSInteger*"] ) {
  pMyNSInteger = va_arg(myArgumentList,NSInteger*);
} else if ([myType isEqualToString:@"CGFloat"]) {
  myCGFloat = va_arg(myArgumentList, CGFloat);
} else if ([myType isEqualToString:@"CGFloat*"]) {
  pMyCGFloat = va_arg(myArgumentList, CGFloat*);
} ... etc
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to