2

I am trying to create a list of UIEdgeInsets instances in Objective-C. Since they are not id type, I couldn't add them into an array.

What I want to do is something like this:

NSArray *contentInsets = @[{10, 20, 30, 40}, {10, 10, 10, 10}, ...];

Thanks.

Ozgur Vatansever
  • 49,246
  • 17
  • 84
  • 119

1 Answers1

3

You can use following to store UIEdgeInsets in NSArray:

NSStringFromUIEdgeInsets

For example:

NSArray *contentInsets = @[NSStringFromUIEdgeInsets(UIEdgeInsetsMake(10, 20, 30, 40)), NSStringFromUIEdgeInsets(UIEdgeInsetsMake(10, 10, 10, 10)), ...];

And to retrieve back:

UIEdgeInsetsFromString
gagarwal
  • 4,224
  • 2
  • 20
  • 27