views:
243answers:
4Assigning the exact same immutable string to the address is by design. It is a performance optimization.
A different way to accomplish your goal would be:
NSString* param1 = [NSString stringWithFormat:@"string1"];
NSString* param2 = [NSString stringWithFormat:@"string2"];
NSString* param3 = [NSString stringWithFormat:@"string3"];
[controller addObjects:[NSArray arrayWithObjects:param1,param2,param3,nil]];
[param1 release];
[param2 release];
[param3 release];
edit: Just using the stringWithFormat is sufficent it turns out
[controller addObjects:[NSArray arrayWithObjects:[NSString stringWithFormat:@"string1"],
[NSString stringWithFormat:@"string2"],
[NSString stringWithFormat:@"string3"],nil]];
I wouldn't call this type of limitation a bug. A data driven view typically expects to use the content objects as keys. For example, in NSOutlineView you have these two methods:
– itemAtRow:
– rowForItem:
Where item is some arbitrary object either supplied via bindings, or through the data source mechanism. If the objects in the outline view aren't unique, how is NSOutlineView supposed to reliably implement rowForItem:? If the same object appeared N times in the outline view, there would be N rows for it.
NSCollectionView doesn't seem to have an interface that precludes multiple instances of the same content object, but I think this expectation is typical of data driven views.
You should use unique content objects.
I have a question about your toy program - you have buttons in your NSViewItem - did you get them to actually do anything? Could you kindly share on how did you manage them to work is you did - what/how you connected/bound those buttons, etc.
Thank you very much for the response :)