当前位置: 首页>>代码示例>>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;未经允许,请勿转载。