Bug 6520 - NSCopying protocol not implemented
Summary: NSCopying protocol not implemented
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- enhancement
Target Milestone: 7.0.6
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2012-08-13 20:10 UTC by Adam Kemp
Modified: 2013-12-19 06:17 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Adam Kemp 2012-08-13 20:10:49 UTC
Many classes in CocoaTouch implement the NSCopying protocol, but this protocol is not exposed in any way by the C# wrappers provided by MonoTouch. In order to get around this I had to write code like this:

var object = GetSomeObject();
var objectCopy = new ObjectType(Messaging.IntPtr_objc_msgSend(object, selCopy.Handle));

I'm assuming this isn't implemented because you usually don't need it, but when you do need it it can be a pain working around it.

The specific class I was trying to use it on was CAAnimation.
Comment 1 Sebastien Pouliot 2012-09-05 10:22:34 UTC
This was added to our internal "improvements" board for discussions, Thanks.
Comment 2 pperera 2013-11-20 19:20:26 UTC
any updates on this? It still doesn't seems to be implemented.
Comment 3 Sebastien Pouliot 2013-12-02 14:28:28 UTC
Right now the `NS[Mutable]Copying` protocol(s) are not directly exposed in our API. They involve a lot of small changes in the class libraries for something that are not commonly used.

OTOH `NSObject` already provide a `Copy` method [1], which returns the result of `NSCopying` `copyWithZone:` and has the advantage of being part of `NSObject` itself (i.e. not re-declared in several subclasses).

p.s. If this does not solve your use case(s) could you share more details about it/them ?

[1] https://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/copy
Comment 4 Adam Kemp 2013-12-02 15:54:19 UTC
My particular use case was an experiment that ultimately failed for other reasons, but I believe the Copy method you described would have been sufficient for what I was trying to do.
Comment 5 Sebastien Pouliot 2013-12-06 12:45:36 UTC
Thanks for the feedback.

Future versions of Xamarin.iOS and Xamarin.Mac will have support for NS[Mutable]Copying (piggybacked with the similar NS[Secure]Coding changes).

monotouch/master: 4e134986a81c3de08a73bd28b42b26304e232e58
xamcore/master: 63674785f54557feed79d90dfba0be0e05c1b95b

QA: automated testing for protocol conformance added
Comment 6 PJ 2013-12-11 18:45:59 UTC
This fix is planned to be released with Xamarin.iOS 7.0.6, which should hit the beta channel before December 23rd.
Comment 7 Sadik Ali 2013-12-19 06:17:51 UTC
I have verified the issue and found that mutable copy method is implemented in NSObject class

refer screen shot:
http://screencast.com/t/xinjRO3aL

Checked with:
All Mac
XS 4.2.3 (build 23)
X iOS 7.0.6.164