Re: Determining whether a dictionary is mutable or not

2011-01-15 Thread Tito Ciuro
Hi Ken, On Jan 15, 2011, at 7:36 AM, Ken Ferry wrote: I'm not sure this has been made clear: It is intentional that it is difficult to determine whether a dictionary is mutable. That's because you shouldn't do it. Whether a dictionary is mutable _to_you_ is a matter of what's in the

Re: Determining whether a dictionary is mutable or not

2011-01-15 Thread Ken Thomases
On Jan 15, 2011, at 5:38 AM, Tito Ciuro wrote: On Jan 15, 2011, at 7:36 AM, Ken Ferry wrote: I'm not sure this has been made clear: It is intentional that it is difficult to determine whether a dictionary is mutable. That's because you shouldn't do it. Whether a dictionary is mutable

Re: Determining whether a dictionary is mutable or not

2011-01-15 Thread Tito Ciuro
On Jan 15, 2011, at 1:04 PM, Ken Thomases wrote: On Jan 15, 2011, at 5:38 AM, Tito Ciuro wrote: On Jan 15, 2011, at 7:36 AM, Ken Ferry wrote: I'm not sure this has been made clear: It is intentional that it is difficult to determine whether a dictionary is mutable. That's because

Re: Determining whether a dictionary is mutable or not

2011-01-15 Thread Jean-Daniel Dupas
Le 15 janv. 2011 à 13:18, Tito Ciuro a écrit : On Jan 15, 2011, at 1:04 PM, Ken Thomases wrote: On Jan 15, 2011, at 5:38 AM, Tito Ciuro wrote: On Jan 15, 2011, at 7:36 AM, Ken Ferry wrote: I'm not sure this has been made clear: It is intentional that it is difficult to determine

Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Hello, Trying to determine whether an NSDictionary is mutable or not fails with these two tests: // Variable info could be NSDictionary or NSMutableDictionary. Assume it's an NSDictionary. BOOL isKindOfClass = [info isKindOfClass:[NSMutableDictionary class]]; BOOL respondsToSelector = [info

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Mike Abdullah
If you want to test if a dictionary is immutable, you are almost certainly doing it wrong. When passed a dictionary in to a method either: A) Make a mutable copy if that's what you need B) -copy it if you want it to be immutable. (This is not inefficient as it sounds because immutable objects

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Hi Mike, Given that the caller can pass a NSDictionary or an NSMutableDictionary, I wanted to test its mutability before calling setObject:forKey:. In order to avoid calling mutableCopy each time, I thought it would be more efficient to test it and then call mutableCopy only when needed.

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread jonat...@mugginsoft.com
On 14 Jan 2011, at 10:48, Tito Ciuro wrote: Hello, Trying to determine whether an NSDictionary is mutable or not fails with these two tests: // Variable info could be NSDictionary or NSMutableDictionary. Assume it's an NSDictionary. BOOL isKindOfClass = [info

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread jonat...@mugginsoft.com
On 14 Jan 2011, at 11:25, Tito Ciuro wrote: Hi Mike, Given that the caller can pass a NSDictionary or an NSMutableDictionary, I wanted to test its mutability before calling setObject:forKey:. In order to avoid calling mutableCopy each time, I thought it would be more efficient to test

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Roland King
On 14-Jan-2011, at 7:25 PM, Tito Ciuro wrote: Hi Mike, Given that the caller can pass a NSDictionary or an NSMutableDictionary, I wanted to test its mutability before calling setObject:forKey:. In order to avoid calling mutableCopy each time, I thought it would be more efficient to

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Hi Jonathan, On Jan 14, 2011, at 12:34 PM, jonat...@mugginsoft.com wrote: On 14 Jan 2011, at 11:25, Tito Ciuro wrote: Hi Mike, Given that the caller can pass a NSDictionary or an NSMutableDictionary, I wanted to test its mutability before calling setObject:forKey:. In order to avoid

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Roland King
On 14-Jan-2011, at 7:36 PM, Roland King wrote: On 14-Jan-2011, at 7:25 PM, Tito Ciuro wrote: Hi Mike, Given that the caller can pass a NSDictionary or an NSMutableDictionary, I wanted to test its mutability before calling setObject:forKey:. In order to avoid calling mutableCopy each

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Clark Cox
On Fri, Jan 14, 2011 at 3:34 AM, jonat...@mugginsoft.com jonat...@mugginsoft.com wrote: On 14 Jan 2011, at 11:25, Tito Ciuro wrote: Hi Mike, Given that the caller can pass a NSDictionary or an NSMutableDictionary, I wanted to test its mutability before calling setObject:forKey:. In order

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread jonat...@mugginsoft.com
On 14 Jan 2011, at 11:43, Clark Cox wrote: On Fri, Jan 14, 2011 at 3:34 AM, jonat...@mugginsoft.com jonat...@mugginsoft.com wrote: On 14 Jan 2011, at 11:25, Tito Ciuro wrote: Hi Mike, Given that the caller can pass a NSDictionary or an NSMutableDictionary, I wanted to test its

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Hi Pablo, On Jan 14, 2011, at 1:35 PM, Pablo Pons Bordes wrote: Hello, To determine if a dictionary is mutable or Inmutable you just need to use the isKindOfClass method, instead of use respondsToSelector. I did a test to reproduce your problem and couldn't reproduce your problem, so

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Pablo Pons Bordes
Hello, To determine if a dictionary is mutable or Inmutable you just need to use the isKindOfClass method, instead of use respondsToSelector. I did a test to reproduce your problem and couldn't reproduce your problem, so my conclusion is that actually you are receiving a mutable Dictionary

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Pablo Pons Bordes
So why I'm not able to reproduce your problem? There is three posible case: 1.- I maid wrong the Test. 2.- You are making wrong If statement (maybe an assignment instead of compare ) 3.- Something really estrange happens. good luck Pablo El 14/01/2011, a las 12:44, Tito Ciuro escribió: Hi

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Roland King
On 14-Jan-2011, at 8:44 PM, Tito Ciuro wrote: Hi Pablo, On Jan 14, 2011, at 1:35 PM, Pablo Pons Bordes wrote: Hello, To determine if a dictionary is mutable or Inmutable you just need to use the isKindOfClass method, instead of use respondsToSelector. I did a test to reproduce

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Andy Lee
On Jan 14, 2011, at 7:57 AM, Roland King wrote: Again let me say that if the signature to your method is -(void)doSomethingWithADictionary:(NSDictionary*)dictionary; you shouldn't be trying to figure out whether that dictionary is mutable and mutate it. Yup. If you want it to

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Corbin Dunn
On Jan 14, 2011, at 4:44 AM, Tito Ciuro wrote: Hi Pablo, On Jan 14, 2011, at 1:35 PM, Pablo Pons Bordes wrote: Hello, To determine if a dictionary is mutable or Inmutable you just need to use the isKindOfClass method, instead of use respondsToSelector. I did a test to reproduce

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Tito Ciuro
Thanks a lot everyone for the great feedback. I really appreciate it! :-) Cheers, -- Tito On Jan 14, 2011, at 6:39 PM, Corbin Dunn wrote: On Jan 14, 2011, at 4:44 AM, Tito Ciuro wrote: Hi Pablo, On Jan 14, 2011, at 1:35 PM, Pablo Pons Bordes wrote: Hello, To determine if a

Re: Determining whether a dictionary is mutable or not

2011-01-14 Thread Ken Ferry
I'm not sure this has been made clear: It is intentional that it is difficult to determine whether a dictionary is mutable. That's because you shouldn't do it. Whether a dictionary is mutable _to_you_ is a matter of what's in the header for the method you obtained it from. Suppose that some