當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ios.getter方法代碼示例

本文整理匯總了TypeScript中utils/utils.ios.getter方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ios.getter方法的具體用法?TypeScript ios.getter怎麽用?TypeScript ios.getter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils/utils.ios的用法示例。


在下文中一共展示了ios.getter方法的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 };
    }
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:7,代碼來源:file-system-access.ios.ts

示例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;
        }
    }
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:32,代碼來源:file-system-access.ios.ts

示例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;
        }
    }
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:33,代碼來源:file-system-access.ios.ts

示例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;
    }
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:7,代碼來源:file-system-access.ios.ts

示例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;
 }
開發者ID:transistorsoft,項目名稱:nativescript-background-geolocation-lt,代碼行數:8,代碼來源:api.ios.ts

示例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();
        }
    }
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:10,代碼來源:file-system-access.ios.ts

示例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));
         }
     }
 }
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:11,代碼來源:file-system-access.ios.ts

示例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));
            }
        }
    }
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:12,代碼來源:file-system-access.ios.ts

示例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"));
        }
    }
}
開發者ID:phattranky,項目名稱:nativescript-marketplace-demo,代碼行數:17,代碼來源:navigator.ts

示例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);
            }
        }
    }
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:44,代碼來源:file-system-access.ios.ts


注:本文中的utils/utils.ios.getter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。