• 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: printing arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printing arrays


  • Subject: Re: printing arrays
  • From: Kyle Sluder <email@hidden>
  • Date: Sat, 03 Nov 2012 08:42:00 -0700

On Nov 2, 2012, at 10:18 PM, "Gerriet M. Denkmann" <email@hidden> wrote:

>
> On 3 Nov 2012, at 00:35, Kyle Sluder <email@hidden> wrote:
>
>> If this is just for debugging purposes, you could swizzle -[NSArray
>> description] and -[NSDictionary description].
>
> I tried a Category for NSArray like:

You must never use a category to replace an existing method implementation. Swizzling is the only approach that will work.

>
> Now this:
> 	NSLog(@" Bad Array: %@", array);
> 	NSLog(@" Good Array with description: %@", [array description]);
> prints:
> 2012-11-03 12:04:14.548 Writing[84446:303]  Bad Array: (
>     "\U0e01\U0e38\U0e0d\U0e41\U0e08",
>     "\U0e04\U0e38\U0e13\U0e04\U0e48\U0e32"
> )
> 2012-11-03 12:04:14.548 Writing[84446:303]  Good Array with description:
> (
> 	กุญแจ
> 	คุณค่า
> )
>
>  Is there a way to make the first NSLog work?
> I seem to remember that it calls something like debuggingDescription, which, if not overridden calls description.

Yeah, try sizzling -debugDescription too. And perhaps -debugDictionary (though that might be an Omni-ism).

>
> I have no experience with swizzling.

Luckily, the term is easily Googleable.

Or you can just take Quincy's advice and write your own function or category method that prints correctly.

--Kyle Sluder
_______________________________________________

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: printing arrays
      • From: "Gerriet M. Denkmann" <email@hidden>
    • Re: printing arrays
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >printing arrays (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: printing arrays (From: Kyle Sluder <email@hidden>)
 >Re: printing arrays (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Spotlight in my app not finding anything
  • Next by Date: Re: printing arrays
  • Previous by thread: Re: printing arrays
  • Next by thread: Re: printing arrays
  • Index(es):
    • Date
    • Thread