本文整理匯總了TypeScript中utils/utils.ios類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ios類的具體用法?TypeScript ios怎麽用?TypeScript ios使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ios類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: exists
private exists(path: string): { exists: boolean, isDirectory: boolean } {
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
var isDirectory = new interop.Reference(interop.types.bool, false);
var exists = fileManager.fileExistsAtPathIsDirectory(path, isDirectory);
return { exists: exists, isDirectory: isDirectory.value };
}
示例2: getFile
public getFile(path: string, onError?: (error: any) => any): { path: string; name: string; extension: string } {
try {
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
var exists = fileManager.fileExistsAtPath(path);
if (!exists) {
var parentPath = this.getParent(path, onError).path;
if (!fileManager.createDirectoryAtPathWithIntermediateDirectoriesAttributesError(parentPath, true, null) ||
!fileManager.createFileAtPathContentsAttributes(path, null, null)) {
if (onError) {
onError(new Error("Failed to create file at path '" + path + "'"));
}
return undefined;
}
}
var fileName = fileManager.displayNameAtPath(path);
return {
path: path,
name: fileName,
extension: this.getFileExtension(path)
};
}
catch (exception) {
if (onError) {
onError(exception);
}
return undefined;
}
}
示例3: getFolder
public getFolder(path: string, onError?: (error: any) => any): { path: string; name: string } {
try {
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
var exists = this.folderExists(path);
if (!exists) {
try {
fileManager.createDirectoryAtPathWithIntermediateDirectoriesAttributesError(path, true, null)
}
catch (ex) {
if (onError) {
onError(new Error("Failed to create folder at path '" + path + "': " + ex));
}
return undefined;
}
}
var dirName = fileManager.displayNameAtPath(path);
return {
path: path,
name: dirName
};
}
catch (ex) {
if (onError) {
onError(new Error("Failed to create folder at path '" + path + "'"));
}
return undefined;
}
}
示例4: getKnownPath
private getKnownPath(folderType: number): string {
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
var paths = fileManager.URLsForDirectoryInDomains(folderType, NSSearchPathDomainMask.UserDomainMask);
var url = paths.objectAtIndex(0);
return url.path;
}
示例5: getAdapter
private static getAdapter() {
if (!this.adapter) {
let app = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
this.adapter = TSLocationManager.sharedInstance();
this.adapter.viewController = app.keyWindow.rootViewController;
}
return this.adapter;
}
示例6: getLastModified
public getLastModified(path: string): Date {
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
var attributes = fileManager.attributesOfItemAtPathError(path);
if (attributes) {
return attributes.objectForKey("NSFileModificationDate");
} else {
return new Date();
}
}
示例7: deleteEntity
private deleteEntity(path: string, onError?: (error: any) => any) {
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
try {
fileManager.removeItemAtPathError(path);
}
catch (ex) {
if (onError) {
onError(new Error("Failed to delete file at path '" + path + "': " + ex));
}
}
}
示例8: rename
public rename(path: string, newPath: string, onError?: (error: any) => any) {
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
try {
fileManager.moveItemAtPathToPathError(path, newPath);
}
catch (ex) {
if (onError) {
onError(new Error("Failed to rename '" + path + "' to '" + newPath + "': " + ex));
}
}
}
示例9: openLink
export function openLink(view: any) {
var url = view.tag;
if (url) {
if (isIOS) {
var nsUrl = NSURL.URLWithString(url);
var sharedApp = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
if (sharedApp.canOpenURL(nsUrl)) {
sharedApp.openURL(nsUrl);
}
}
else if (isAndroid) {
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url));
var activity = frame.topmost().android.activity;
activity.startActivity(android.content.Intent.createChooser(intent, "share"));
}
}
}
示例10: enumEntities
private enumEntities(path: string, callback: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error) => any) {
try {
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
try {
var files = fileManager.contentsOfDirectoryAtPathError(path);
}
catch (ex) {
if (onError) {
onError(new Error("Failed to enum files for folder '" + path + "': " + ex));
}
return;
}
var file;
var i;
var info;
var retVal;
for (i = 0; i < files.count; i++) {
file = files.objectAtIndex(i);
info = {
path: this.concatPath(path, file),
name: file
};
if (!this.folderExists(this.joinPath(path, file))) {
info.extension = this.getFileExtension(info.path);
}
retVal = callback(info);
if (retVal === false) {
// the callback returned false meaning we should stop the iteration
break;
}
}
}
catch (ex) {
if (onError) {
onError(ex);
}
}
}