Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
I am trying to bind the ShareKit API but several methods return a NSMutableArray
using latest stable versions of mono/monotouch
running bTouch gives an error as NSMutableArray is not in the framework.
Other people have run into this problem: http://monotouch.2284126.n4.nabble.com/NSMutableArray-unavailable-BTouch-guru-needed-td3515333.html
You can bind NSMutableArray values as NSArray, unless the API requires you to add/remove values to the mutable array.
Is there a reason the API returns an NSMutableArray as opposed to an NSArray?
If the API is NSMutableArray getValues(), for example, is it expected that adding/removing or changing elements in that array are reflected in the object instance that you called getValues() on?
Sorry for the delay in response.
Looking here: http://getsharekit.com/docs/ I cannot see any examples of NSMutableArray being used. Something may become apparent when I really try to use it in anger. Currently my basic binding seems to work (as far as I have tested it).
Okay, if you find anything, let us know and we can consider binding NSMutableArray (it probably wouldn't be hard).
I'm binding obj-c methods with specific documentation saying it requires add/remove/move functionality of NSMutableArray. Here's a method example:
+ (id)sectionWithHeaderTitle:(NSString *)sectionHeaderTitle
It would be great if we could get this functionality soon.
I guess now we have an actual use-case.
In general, do not pass NSArrays unless you have a real reason to do so. In general, use C# arrays of NSObjects to expose a strongly typed API. So instead of:
void AddViews (NSArray views);
void AddViews (NSView  views);
On the particular case of the sample that takes an NSMutableArray, please provide a pointer to the code.
In general, we do not expose NSMutableArray as a design decision. If an API requires an NSMutableArray, you can use an NSObject as the argument meanwhile and create your own binding, but in general, it means that the library is poorly designed.
Not sure by your comment that "the library is poorly designed" if it has methods taking in NSMutableArray, or properties that are NSMutableArray. Isn't this just a list that's updatable, akin to System.Collections.Generic.List in C#? This seems like a common use case to me.
Is there any chance of getting a reason behind the decision to not expose NSMutableArray? I keep getting asked why it's not there.
I'm also quite curious about this, and the argumentation behind why "it means that the library is
Libraries, Facebook-Connect being one of them, makes use of NSMutableArrays.
The reason why it is poorly designed is because you can alter the state of the collection without the object that exposes the array that the changes took place.
For example, if you had a:
(NSMutableArray *) employees;
You could add and remove employees at will, without the object knowing that you did so.
A well designed API would expose instead:
- (NSArray *) employees;
- (void) addEmployee: (Employee *);
- (void) removeEmployee: (Employee *);
Both of those would update the internal mutable array and any other links or components that are needed internally.
That is why no single Apple API exposes NSMutableArray as a return value from a property or method.
That being said, we added NSMutableArray in MonoTouch 5.2.3, but you will get a warning message every time you use it.
yeah, that makes sense :D thx