• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript utils.ios类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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 };
    }
开发者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类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript utils.layout类代码示例发布时间:2022-05-25
下一篇:
TypeScript utils.ad类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap