java - Convert JavaUtilList to NSArray? -
using j2objc have javautillist:
var javaarraylist:javautillist = javaarraylist()
i want convert list nsarray:
var arr:[string] = // ????
how can convert javautillist objective-c/swift nsarray?
you use iterator
cycle through every item:
static inline nsarray *arraywithjavautillist(id <javautillist> list) { nsmutablearray *array = [[nsmutablearray alloc] init]; id <javautiliterator> iterator = [list iterator]; while ([iterator hasnext]) { id object = [iterator next]; [array addobject:object]; } return [nsarray arraywitharray:array]; }
Comments
Post a Comment