• 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: How to recognize mutability?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to recognize mutability?


  • Subject: Re: How to recognize mutability?
  • From: Ronald Oussoren <email@hidden>
  • Date: Wed, 20 Feb 2013 09:22:53 +0100

On 20 Feb, 2013, at 9:10, Gerriet M. Denkmann <email@hidden> wrote:

> I am trying to build my own version of NSKeyed(Un)Archiver.
>
> But I do not know how to recognise mutability.

Use "classForKeyedArchiver" (or one of the other variants) to detect as which class an object wants to be archived.

This will return [NSMutableString class] for mutable strings and [NSString class] for immutable ones.

Ronald

>
> 1. use isKindOfClass: [NSMutableString class]
> 	disadvantage: all strings turn out to be mutable
>
> 2. use respondsToSelector: @selector(appendString:)
> 	disadvantage: all strings turn out to be mutable
>
> 3. mutate the string (in a @try block) if exception, then immutable, else mutate the string back.
> 	disadvantage: very inelegant and probably quite slow
>
> 4. use some undocumented (which?) method
> 	disadvantage: might break with next OS release
>
> 5. anything else?
>
> Gerriet.
>
> P.S.
> I want my own archiver for 2 reasons:
> 1. NSKeyedArchiver can store only certain strings
> 2. It creates files, which are 10 times bigger than my version (and 5 times bigger than NSArchiver)
>
> _______________________________________________
>
> 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


_______________________________________________

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: 
 >How to recognize mutability? (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: How to recognize mutability?
  • Next by Date: Re: How to recognize mutability?
  • Previous by thread: How to recognize mutability?
  • Next by thread: Re: How to recognize mutability?
  • Index(es):
    • Date
    • Thread