Hello,
I was trying to implement a “duplicate” button to (obviously) duplicate selected items in a table view and though I believed it to be a simple task to do, I do get a result, but not what I expected.
The item(s) actually get duplicated (with a " copy" added at the end of the title, but the original entry also receives this new addition. Also, if i click on either the original or the copy, both gets selected (although this might be related to the fact that the names are the same).
Here is the code i’m using:
set selectedObjectsToDuplicate to theArrayController's selectedObjects()
set selectedObjectsToDuplicateMutable to current application's NSMutableArray's arrayWithCapacity_(255)
selectedObjectsToDuplicateMutable's addObjectsFromArray_(selectedObjectsToDuplicate)
repeat with currentItem in selectedObjectsToDuplicateMutable
set entryTitle to currentItem's valueForKey_("publicationName")
set newEntryTitle to current application's NSString's stringWithString_(((((entryTitle) as string) & " copy") as string))
currentItem's setValue_forKey_(newEntryTitle, "publicationName")
end repeat
theArrayController's addObjects_(selectedObjectsToDuplicateMutable)
Anyone has any idea what could be wrong? Although I create a different NSMutableArray to change the objects, there seems to be a link still between both of them. How is this possible? I saw nothing in the docs that would explain this.
Thanks
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)