mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
New BCL approach & BuildTasks
This commit is contained in:
29
Utils/utils_android.ts
Normal file
29
Utils/utils_android.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export module tk {
|
||||
// TODO: this should be properly organized
|
||||
export module utils {
|
||||
export class Collections {
|
||||
public static stringArrayToStringSet(str: string[]): any {
|
||||
var hashSet = new java.util.HashSet();
|
||||
if ("undefined" != typeof str) {
|
||||
for (var element in str) {
|
||||
hashSet.add('' + str[element]);
|
||||
}
|
||||
}
|
||||
return hashSet;
|
||||
}
|
||||
|
||||
public static stringSetToStringArray(stringSet: any): string[] {
|
||||
var arr = [];
|
||||
if ("undefined" != typeof stringSet) {
|
||||
var it = stringSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
var element = '' + it.next();
|
||||
arr.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Utils/utils_ios.ts
Normal file
27
Utils/utils_ios.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export module tk {
|
||||
// TODO: this should be properly organized
|
||||
export module utils {
|
||||
export class Collections {
|
||||
public static jsArrayToNSArray(str: string[]): any {
|
||||
var arr = new Foundation.NSMutableArray();
|
||||
if ("undefined" != typeof str) {
|
||||
for (var element in str) {
|
||||
arr.addObject(str[element]);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static nsArrayToJSArray(a: any): string[] {
|
||||
var arr = [];
|
||||
if ("undefined" != typeof a) {
|
||||
for (var i = 0; i < a.count(); i++) {
|
||||
arr.push(a.objectAtIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user