• 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: print object by %@
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: print object by %@


  • Subject: Re: print object by %@
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Thu, 22 Jul 2010 23:22:25 +0200

So replace printf by asl_log.

And if this is not convenient enough:

#define MyLog(fmt, ...) asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "%s", [[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String])

Or if you prefere a function

void MyLog(NSString *fmt, ...) {
  va_list args;
  va_start(args, fmt);
  NSString *str = [[NSString alloc] initWithFormat:fmt arguments:args];
    asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "%s", [str UTF8String]);
    [str release];
  va_end(args);
}


Le 22 juil. 2010 à 19:57, Ariel Feinerman a écrit :

> Thank you for yours, but I am looking for more convenient way, I mean a function for console output, not for debugging like NSLog(),
>
> so I wish:
>
> NSLog(@"object is %@", obj);
> // $ object is [object description]
>
> I would not wish to convert NSString to utf8 for printf(), I wish to use NSString
> 2010/7/22 Jean-Daniel Dupas <email@hidden>
> Le 22 juil. 2010 à 13:32, Ariel Feinerman a écrit :
>
> > Hi developers,
> >
> > I search in google, but can see nothing. Is there Cocoa fuction for objects
> > like printf(), without timestamps?
>
>
> Not the most efficient way, but straightforward for debugging purpose:
>
> printf("%s", [[NSString stringWithFormat:@"format string", args] UTF8String]);
>
> -- Jean-Daniel
>
>
>
>
>
>
>
> --
> best regards
> Ariel

-- Jean-Daniel




_______________________________________________

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

References: 
 >print object by %@ (From: Ariel Feinerman <email@hidden>)
 >Re: print object by %@ (From: Jean-Daniel Dupas <email@hidden>)
 >Re: print object by %@ (From: Ariel Feinerman <email@hidden>)

  • Prev by Date: Re: Deselect keyboard focus of an NSMatrix cell
  • Next by Date: LSUIElement vs applicationShouldTerminate:
  • Previous by thread: Re: print object by %@
  • Next by thread: Small caps in NSTextView
  • Index(es):
    • Date
    • Thread