zoukankan      html  css  js  c++  java
  • How to use NSRequest in Delphi XE4

    //Demo How to use NSRequest..
    procedure TiOSWebBrowserService.DoNavigate(const URL: string);
    var
    NewURL: string;
    NSNewURL: NSURL;
    NSNewURLRequest: NSURLRequest;
    LPath: NSString;
    LFilePath: string;
    LDir, LFileName : string;
    Bundle : Pointer;
    begin
    NewURL := URL;
    if Pos('file://', URL) <> 0 then
    begin
    //extract the file name, the string after file://
    NewURL := Copy(URL, length('file://') + 1, length(URL));
    LDir := ExtractFileDir(NewURL);
    LFileName := ExtractFileName(NewURL);
    if LDir.IsEmpty then
    Bundle := TNSBundle.OCClass.mainBundle
    else
    Bundle := TNSBundle.OCClass.bundleWithPath(NSSTR(LDir));
    LPath := TNSBundle.Wrap(Bundle).pathForResource(NSSTR(LFileName), nil);
    if Assigned(LPath) then
    begin
    LFilePath := UTF8ToString(LPath.UTF8String);
    if not FileExists(LFilePath) then
    raise EFileNotFoundException.Create(SFileNotFound);
    NSNewURL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(LPath));
    end;
    end
    else
    begin
    if Pos('http', URL) = 0 then
    Insert('http://', NewURL, 0);
    NSNewURL := TNSUrl.Wrap(TNSUrl.OCClass.URLWithString(NSStr(NewURL)));
    end;
    NSNewURLRequest:= TNSURLRequest.Wrap(TNSURLRequest.OCClass.requestWithURL(NSNewURL));
    FWebView.loadRequest(NSNewURLRequest);
    FWebView.setFrame(CGRectFromRect(RectF(0, 0, 1, 1)));
    UpdateContentFromControl;
    end;

    //almost same with objective c style 

    ToCheck:  customized tableview cell . color / bg  / font/  in-app purchase subscribe

    Never giveup. Thanks the world.
  • 相关阅读:
    Timer类的常见使用方法
    转:HTTP协议简介
    DS-5新加交叉编译工具
    C++的引用
    C++构造函数的几种使用方法
    Eclipse 快捷键
    eclipse Outline里图标的含义
    Linux 内存映射函数 mmap()函数详解
    Sockit 硬件接口编程——点亮一个LED
    更新Preloader与uboot
  • 原文地址:https://www.cnblogs.com/cnsoft/p/3174748.html
Copyright © 2011-2022 走看看