[Rubycocoa-devel 1250] Re: #to_ns now returns mutable objects

Back to archive index

Laurent Sansonetti lsans****@apple*****
Mon Nov 19 00:29:41 JST 2007


I reverted this change in r2132, because it caused some  
incompatibility problems, for example:

   h = NSMutableDictionary.new
   h['foo'] = []
   [...]
   h['foo'] << 42 # NSInternalInconsistencyException - *** -[NSCFArray  
insertObject:atIndex:]: mutating method sent to immutable object  
(OSX::OCException)

# This is because Array was converted as an NSArray, which isn't  
mutable. In the past a NSMutableArray was used instead.
# This broke rb_nibtool.rb.

Also, #to_ns is now back as before, it doesn't accept a parameter  
anymore. It always returns mutable objects (for string, array and hash).

Laurent

On Nov 6, 2007, at 10:57 PM, Laurent Sansonetti wrote:

> Hi,
>
> After discussion on the IRC channel, we changed the #to_ns method a
> little bit. #to_ns became #to_ns(returns_mutable=true).
> By default, it will return mutable objects, for the classes that
> support this semantic (Array, String, ...).
>
> If you want to get an immutable object like before, you can pass false
> to the method.
>
> This seems more natural to get mutable objects from #to_ns. The
> drawback is that we create a mutable copy by default, but #to_ns is
> normally used by experimented developers, and RubyCocoa anyway does
> the conversion automatically.
>
> Laurent
>
> _______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel




More information about the Rubycocoa-devel mailing list
Back to archive index