@@ -85,17 +85,19 @@ actual sealed class StringDesc {
8585 abstract fun localized (): String
8686
8787 protected fun stringWithFormat (format : String , args : Array <out Any >): String {
88+ // NSString format works with NSObjects via %@, we should change standard format to %@
89+ val objcFormat = format.replace(Regex (" %[\\ .|\\ d]*[a|b|c|d|e|f|s]" ), " %@" )
8890 // bad but objc interop limited :(
8991 // When calling variadic C functions spread operator is supported only for *arrayOf(...)
9092 return when (args.size) {
91- 0 -> NSString .stringWithFormat(format )
92- 1 -> NSString .stringWithFormat(format , args[0 ])
93- 2 -> NSString .stringWithFormat(format , args[0 ], args[1 ])
94- 3 -> NSString .stringWithFormat(format , args[0 ], args[1 ], args[2 ])
95- 4 -> NSString .stringWithFormat(format , args[0 ], args[1 ], args[2 ], args[3 ])
96- 5 -> NSString .stringWithFormat(format , args[0 ], args[1 ], args[2 ], args[3 ], args[4 ])
93+ 0 -> NSString .stringWithFormat(objcFormat )
94+ 1 -> NSString .stringWithFormat(objcFormat , args[0 ])
95+ 2 -> NSString .stringWithFormat(objcFormat , args[0 ], args[1 ])
96+ 3 -> NSString .stringWithFormat(objcFormat , args[0 ], args[1 ], args[2 ])
97+ 4 -> NSString .stringWithFormat(objcFormat , args[0 ], args[1 ], args[2 ], args[3 ])
98+ 5 -> NSString .stringWithFormat(objcFormat , args[0 ], args[1 ], args[2 ], args[3 ], args[4 ])
9799 6 -> NSString .stringWithFormat(
98- format ,
100+ objcFormat ,
99101 args[0 ],
100102 args[1 ],
101103 args[2 ],
@@ -104,7 +106,7 @@ actual sealed class StringDesc {
104106 args[5 ]
105107 )
106108 7 -> NSString .stringWithFormat(
107- format ,
109+ objcFormat ,
108110 args[0 ],
109111 args[1 ],
110112 args[2 ],
@@ -114,7 +116,7 @@ actual sealed class StringDesc {
114116 args[6 ]
115117 )
116118 8 -> NSString .stringWithFormat(
117- format ,
119+ objcFormat ,
118120 args[0 ],
119121 args[1 ],
120122 args[2 ],
@@ -125,7 +127,7 @@ actual sealed class StringDesc {
125127 args[7 ]
126128 )
127129 9 -> NSString .stringWithFormat(
128- format ,
130+ objcFormat ,
129131 args[0 ],
130132 args[1 ],
131133 args[2 ],
0 commit comments