本文整理汇总了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);
}
}
}