Tirna
Tirna

Reputation: 533

Incorrect argument labels in call to dynamically created multidimensional array

I get the following errors when trying to create a multidimensioanl array dynamically:

Incorrect argument labels in call (have 'count:repeatedValue:', expected 'unsafeUninitializedCapacity:initializingWith:')

Replace 'count: languageCount, repeatedValue' with 'unsafeUninitializedCapacity: languageCount, initializingWith'

and when I accept the auto correction suggestion, I then get:

Cannot convert value of type '[Any]' to expected argument type '(inout UnsafeMutableBufferPointer<_>, inout Int) throws -> Void'

which doesn't offer a fix button.

I don't understand these errors.

let numColumns = wordsInLanguageCount.max() ?? 0
let numRows = languageCount
var tableViewWords: [[Int]] = Array(count: languageCount, repeatedValue: [])

Upvotes: 1

Views: 122

Answers (1)

Shamas S
Shamas S

Reputation: 7549

For me the following runs without error on Swift5

let languageCount = 10    // This is an Int
var tableViewWords: [[Int]] = Array(repeating: [], count: languageCount)

Upvotes: 2

Related Questions