Is it possible to apply "AnyObject" to a quick structure

I have a quick method that gets the structure as a parameter. Since the structures are not bound to objective-c, this method is invisible in the bridge header.
I was forced to create a new "identical" method that gets " AnyObject" instead of the structure required by the original method.

Now I am tasked with creating quick structures from " AnyObject". Is it possible to "insert" " AnyObject" into the quick structure in this case?

Am I forced to write a boiler plate to build a quick structure out of AnyObject?

I can send NSDictionaryrepresenting key-value pairs of structs. Does it help anyway?

For instance:

Swift

struct Properties {
  var color = UIColor.redColor()
  var text = "Some text" 
}

class SomeClass : UIViewController {
  func configure(options : Properties) {
    // the original method 
    // not visible from 
  }
  func wrapObjC_Configure(options : AnyObject) {
    // Visible to objective-c
    var convertedStruct = (options as Properties) // cast to the swift struct
    self.configure(convertedStruct)
  }
}

Objective-c

SomeClass *obj = [SomeClass new]
[obj wrapObjC_Configure:@{@"color" : [UIColor redColor],@"text" : @"Some text"}]
+4
2

NSValue , NSValue, struct,

NSValue :

@interface NSValue (Properties)
+ (instancetype)valuewithProperties:(Properties)value;
@property (readonly) Properties propertiesValue;
@end

@implementation NSValue (Properties)
+ (instancetype)valuewithProperties:(Properties)value
{
    return [self valueWithBytes:&value objCType:@encode(Properties)];
}
- (Properties) propertiesValue
{
    Properties value;
    [self getValue:&value];
    return value;
}
@end

NSValue - https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSValue_Class/

+1

anyObject . AnyObject .

Any, , .

0

All Articles