Skip navigation.
 
mlRe: @property question
FROM : Craig Hopson
DATE : Tue May 13 18:49:35 2008

No, not using bindings, but good point & yes, the param type was a typo.
While everything 'seems' to be working now, the info that I got in the 
debugger when I was seeing problems looked suspiciously like the state 
of things when an object has been released but is then referenced.  I 
need to dig deeper and make sure that I'm not going to be bitten later 
on - like in production code...

Thanks for all of the input.
-Craig

On May 12, 2008, at 5:20 PM, Quincey Morris wrote:

>
> On May 12, 2008, at 15:19, Craig Hopson wrote:
>

>> I think I've been the victim of some side effect that I cannot 
>> track down. With no other changes, I tried again with each style,
>>     [ self.fieldArray addObject:inFoo ];
>>     [ fieldArray addObject:inFoo ];
>> replacing all occurrences for each test, and both work - what I 
>> would have expected.

>
> Incidentally, neither version is KVO-compliant. If you happen to 
> have something (e.g. a NSArrayController) bound to the array 
> property, to show Foos in the user interface, the effect of 
> addObject (and therefore addFoo) will be to leave what's displayed 
> out of date. This could possibly lead to unpredictable behavior or a 
> crash.
>
> The KVO-compliant way to add something to an array property would be 
> something like this:
>
> - (void)addFoo:( Bar* )inFoo
> {
>     [ [self mutableArrayValueForKey:@"fieldArray"] addObject:inFoo ];
> }
>
> P.S. I just noticed that the inFoo looks like it needs to be a Foo*, 
> not a Bar*. I assume this was just a typo when you stripped down 
> your example for posting?

Related mailsAuthorDate
ml@property question Craig Hopson May 12, 23:30
mlRe: @property question Shawn Erickson May 12, 23:42
mlRe: @property question mmalc crawford May 12, 23:52
mlRe: @property question Craig Hopson May 13, 00:19
mlRe: @property question Phoenix Draco May 13, 00:42
mlRe: @property question Clark Cox May 13, 00:51
mlRe: @property question Quincey Morris May 13, 01:20
mlRe: @property question Craig Hopson May 13, 18:49
mlRe: @property question Roland King May 14, 02:41
mlRe: @property question Kyle Sluder May 14, 04:41
mlRe: @property question Chris Hanson May 14, 05:11