• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: printf
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printf


  • Subject: Re: printf
  • From: "Clark Cox" <email@hidden>
  • Date: Thu, 13 Dec 2007 07:03:18 -0800

On Dec 13, 2007 6:40 AM, Roland Silver <email@hidden> wrote:
> Is there a function in one of the frameworks that's like printf, but
> allows the output conversion '%@' in its template? Eg
>
>    likePrintf("%@ is allowable", @"this string");
> or better:
>    likePrintf(@"%@ is allowable", @"this string");

No, but it's relatively easy to write your own:

int likePrintf(NSString *format, ...) {
    va_list args;
    va_start(args, format);

    NSString    *output = [[NSString alloc] initWithFormat: format
arguments: args];
    va_end(args);

    int result  = printf("%s", [output UTF8String]);
    [output release];

    return result;
}

--
Clark S. Cox III
email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: printf
      • From: Richard Somers <email@hidden>
    • Re: printf
      • From: James Bucanek <email@hidden>
References: 
 >printf (From: Roland Silver <email@hidden>)

  • Prev by Date: Re: printf
  • Next by Date: Re: Need the Why and How of mouseDragged:
  • Previous by thread: Re: printf
  • Next by thread: Re: printf
  • Index(es):
    • Date
    • Thread