title: Xamarin IOS NSInvalidArgumentException Reason: ***
body: <p>This is an Information for all of you who will step in this Exception: </p>
  
  <blockquote>
    <p>Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: *** -[NSPlaceholderString initWithUTF8String:]: NULL cString</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/ofB6P.png" rel="nofollow noreferrer">IOS Exception</a></p>
  
  <p>I have searched a lot for this error in Web and my Code.
  But all "NSInvalidArgumentException Reason:" are more specific as ***.</p>
  
  <p>This error only appears on IOS in my Case. Android is working very well. Im mainly deploying on Android to test things. So after serveral of commits i started an IOS deploy and nothing worked anymore. </p>
  
  <p>The Error comes through a ListView with enabled Grouping. 
  I'm creating the groups dynamicly with a DueDate given through the ListItems.</p>
  
  <p>My ListView is configured as follow:</p>
  
  <pre><code>&lt;ListView x:Name="AuditList"
           ItemSelected="AuditList_ItemSelected"
           HasUnevenRows="True"
           IsGroupingEnabled="true" 
           GroupDisplayBinding="{Binding LongName}"
           GroupShortNameBinding="{Binding ShortName}"
           SeparatorVisibility="None"&gt;
  </code></pre>
  
  <p>As you all know the Binding for a LongName is the Title. 
  The ShortName is for IOS only and Responsible for the <a href="https://i.stack.imgur.com/DNM2C.png" rel="nofollow noreferrer">Searchlist</a> on the right.</p>
  
  <p><a href="https://docs.microsoft.com/de-de/xamarin/xamarin-forms/user-interface/listview/customizing-list-appearance" rel="nofollow noreferrer">Xamarin ListView Grouping Doc</a></p>
  
  <p>What I was doing is to create a GroupItem without any ShortName...</p>
  
  <pre><code>private GroupedAuditViewItem GetGroup(DateTime date)
      {
          if (date == null)
              return null;
          string longName = CreateGroupName(date);
  
          return new GroupedAuditViewItem() { LongName = longName };
      }
  </code></pre>
  
  <p>In this cases you will get this Exception. 
  But how to prevent this?</p>
  
  <p>You have more than one Path. The simplest would be to delete the ShortName Binding. </p>
  
  <pre><code>GroupShortNameBinding="{Binding ShortName}"
  </code></pre>
  
  <p>An other one is to return a string.Empty ShortName. In this case IOS will display an overlapping empty Searchbar on the right.</p>
  
  <pre><code>return new GroupedAuditViewItem() { LongName = longName, ShortName = shortName };
  </code></pre>
  
  <p>You can also prevent this Exception when you have a good Errorhandling for Example a simple <code>Try Catch</code>...</p>
  
  <p>I have learned a lot the past days and I hope it will help someone out there who is staying at the same problem :)</p>