title: Box Custom Struct in Objective-C
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5691881/how-to-wrap-a-struct-into-nsobject">How to wrap a Struct into NSObject</a><br>
    <a href="https://stackoverflow.com/questions/11252392/can-the-new-clang-objective-c-literals-be-redirected-to-custom-classes">Can the new Clang Objective-C literals be redirected to custom classes?</a>  </p>
  </blockquote>
  
  
  
  <p>I have a custom struct:</p>
  
  <pre><code>typedef struct {
      float f1;
      float f2;
  } MYCustomStruct;
  </code></pre>
  
  <p>that I need to add to an <code>NSArray</code>. I've already written a category to create <code>NSValues</code> of these structs, which I then add to the <code>NSArray</code>, however I'd like to simplify that even further using boxed expressions, if possible. I'd love to be able to do this:</p>
  
  <pre><code>@[@(instanceOfMYCustomStruct)];
  </code></pre>
  
  <p>however, I'm confronted with the following error:</p>
  
  <blockquote>
    <p>Illegal type 'MYCustomStruct' used in a boxed expression</p>
  </blockquote>
  
  <p>Is there a way to use boxed expressions with custom structs?</p>