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.
原文地址:https://www.cnblogs.com/cnsoft/p/3174748.html