Search code examples
objective-cnsmutablearraynsarraycgfloatmultiple-value

CGFloat Multiple value in Objective C


I noticed that in Swift you can pass multiple values into a CGFloat thing that is not possible in Objective c.

Here's an example: let array: [CGFloat] = [0.0, 0.0, 0.0, 0.0]

I need to get multiple values for a NSLayoutConstraint.constant, can you tell me if there is an equivalent function in Objective C? sorry the stupid question, I hope to have explained to you well

I do not know ... maybe using a NSMutableArray


Solution

  • You can define your constants in an NSArray like this:

    self.constants = @[ @8.0, @8.0, @5.0 ];
    

    Then later on your will need to retrieve a value like this

    cell.barHeight.constant = [self.constants[indexPath.row] doubleValue];