How to assign something to nil using Xamarin.iOS - xamarin.ios

I am using a Nuget bindings package in a Xamarin.iOS project, and I am running into trouble when attempting to assign an object to null. According to a link I found to the Objective-C version of the library, you can just assign the objects you want to disable to nil. Unfortunately, C# doesn't have a nil keyword, only null, and the library throws an ArgumentNullException whenever I assign one of its Properties to null. Does anyone know how to specifically assign something in Xamarin.iOS to nil instead of null?

This is a problem in the binding library.
When binding a library, the authors have to opt in to allow users to pass null to parameters, and it seems they forgot to do this (if they don't allow it, you get the ArgumentNullExceptionyou mention).
Contact the authors, and tell them they need to add the [NullAllowed] attribute on the property in question.

Related

How to fix ClassCastException when using localized n-m relations with Smartedit?

In Hybris 6.7.0, using I have a component that contains a localized list of another component.
I have been able to implement this using a n-m localized relationtype to implement a localized list that contains the component.
It works perfectly in CMS cockpit. However, in smartedit, it causes a ClassCastException.
The default converter seems to fail to recognize the collection type and therefore trying to cast the collection to a item model which causes the error.
Is there anyway to implement a localized collection that won't causes the exception in SmartEdit?
I have tried using a map and collection pair for the localization instead of a localized relation but the same problem occurred.
2019-3-7 - Updates: After a series of trial and error, I have realized that the LocalizedCollection will never be called because all localized attribute in Hybris is stored with an item type of MapType, which does not trigger the localizedCollection getter as it check if the localized attributs is of type CollectionType.
It seems to be a bug on SAP side. I am currently trying to come up with a temporary fix for the problem.

xcode8 beta4 not generating the managedObjectContext

I am using a blank core data proj and trying to copy the code from this examples.
https://www.and
rewcbancroft.com/2015/02/18/core-data-cheat-sheet-for-swift-ios-developers/
As there is no managedContext i am not able o proceed.
I am new to IOS programming. Please can anybody share me a simple example that i can start with. But i need it with Xcode8 beta4 version.
I tried many other examples but once i convert them to my current version they are not working.
The error message reads:
Value of type 'ViewController' has no member 'managedObjectContext'
What this means is that somewhere (your screenshot does not show where) you are attempting to assign a value to a property named managedObjectContext, on an instance of your ViewController class. Except that this class doesn't have a property named managedObjectContext, so Swift complains and doesn't compile.
This is not actually a Core Data question-- it's basic Swift. It would happen for any attempt to assign a value to a nonexistent property.
You probably (again, your screenshot does not provide enough detail to be sure) need to create this property on your view controller class, with type NSManagedObjectContext.

Get attribute name from proxy type without using reflections

We use early-bound class for development. But occasionally we use attribute names.
There is a way to do it using reflections, but reflections are not allowed in sandbox plugins.
What are the approaches to getting an attribute from proxy types without relying on reflections?
Opportunity.OpportunityId.AttributeName
You have a couple options:
You can use a RetrieveEntityMetadata to the list of attributes that the entity contains. You won't be able to use any early binding here, but you can inspect the results at run time to see what are valid attributes for the entity.
You could also create a simple utility that uses reflection to auto-generate a class or enum that contains the list of attributes before you actually deploy. Just add the class to your plugin dll and you'd have the benefits of early binding of entity attributes when developing your plugin, without having to do reflection at runtime.

Early Binding of PreImage in Microsoft CRM 2011

The Microsoft CRM advanced developer extensions have gotten me a little spoiled with their early binding for calls made to CRM's webservices.
I'm writing a plugin right now and I'd like to access attributes defined in the pre-image. All the examples cast the preimage as Microsoft.Xrm.Sdk.Entity which uses late binding to access it's attributes. I dislike hardcoding all those string's for attribute names into my plugin and would like to find a method that avoids it by using early binding.
Here is an example of a cast
var preMessageImage = (Microsoft.Xrm.Sdk.Entity)context.PreEntityImages["MyPreImage"];
But I have to use late binding to access the properties
var myProperty = preMessageImate.Properties["MyProperty"];
Is there any way to cast this preimage to an xrm object that has all the properties defined using early binding so I don't have to hardcode all the property names?
You should first use the crmsvcutil tool in the SDK to generate "early-bound" Xrm entities and include that code file in your plugin codebase.
I suggest omitting the 'DataContextName' command-line arg so not context is generated.
For more information check here on MSDN: CrmSvcUtil on MSDN
Next, you should use the ToEntity<T> method on the Entity class to get a strongly-typed specific entity. More info here: ToEntity on MSDN

How to add a display name for a decorator in Visual Studio DSL (Domain Specific Language) Tools?

In my DSL project I have a shape with a number of decorators that are linked to properties on my domain class. But even though ieach decorator has a DisplayName property (set to a meaningfull value) it does not appear in the generated DSL project. (I have not forgtten to use regenerate the t4 files.)
Do I have to create another decorator for each property that only has the display name as a value that I wish to display or is there some other way that I can't figure out right now?
I assume by a display name for the decorator you mean you want the element in the generated DSL to appear as "Example = a_value" where a_value is the actual value and Example is the property name.
What I've done with this in the past is to create second property "ExampleDisplay" that's not browsable and is what the decorator actually points to. I then set the Kind property of the ExampleDisplay to "Calculated". You then need to provide the method that the toolkit tries to call to display the decorator which you can do a partial class.
partial class ExampleElement
{
string GetExampleDisplayValue()
{
return "Example : " + this.Example;
}
}
This is not ideal as you don't get a good way of setting the property on the DSL diagram you have to use the properties window. (There's sometime lags from the property window unless you hook into the update of the underlying property too). Getting the slick editing in the GUI that actual DSL toolkit does maybe possible but I haven't found out how.
It maybe worth ask VSX forums if you haven't already done so.

Resources