Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 检索fire monkey(FMX)中OSX的Delphi运行时应用程序版本和应用程序构建信息_Macos_Delphi_Firemonkey - Fatal编程技术网

Macos 检索fire monkey(FMX)中OSX的Delphi运行时应用程序版本和应用程序构建信息

Macos 检索fire monkey(FMX)中OSX的Delphi运行时应用程序版本和应用程序构建信息,macos,delphi,firemonkey,Macos,Delphi,Firemonkey,我试图找到一个关于如何检索应用程序版本和构建nr的示例,以便在OSX应用程序的帮助框中显示它 在Windows上微不足道,但在Mac上则不然 希望你能帮忙 爱德华我使用我写的代码。简单地说: osxNSBundle.BundleVersion() 代码如下: uses Macapi.Foundation, Macapi.Helpers; osxNSBundle = class private class function MainBundle: NSBundle; public

我试图找到一个关于如何检索应用程序版本和构建nr的示例,以便在OSX应用程序的帮助框中显示它

在Windows上微不足道,但在Mac上则不然

希望你能帮忙


爱德华

我使用我写的代码。简单地说:

osxNSBundle.BundleVersion()
代码如下:

uses
  Macapi.Foundation,
  Macapi.Helpers;

osxNSBundle = class
private
  class function MainBundle: NSBundle;
public
  class function BundlePath: string;
  class function BundleVersionStr: string;
  class procedure BundleVersion(var aMajor,aMinor,aBuild: integer);
end;

implementation

class function osxNSBundle.MainBundle: NSBundle;
begin
  result := TNSBundle.Wrap(TNSBundle.OCClass.mainBundle);
end;

class function osxNSBundle.BundlePath: string;
begin
  result := NSStrToStr(MainBundle.bundlePath);
end;

class function osxNSBundle.BundleVersionStr: string;
begin
  Result := NSStrToStr(TNSString.Wrap(MainBundle.objectForInfoDictionaryKey(StrToNSStr('CFBundleVersion'))));
end;

class procedure osxNSBundle.BundleVersion(var aMajor,aMinor,aBuild: integer);
var lStrArray: TArray<string>;
i: Integer;
begin
  aMajor := 0; aMinor := 0; aBuild := 0;
  lStrArray := BundleVersionStr.Split(['.']);
  if Length(lStrArray)>=3 then
  begin
    aMajor := lStrArray[0].ToInteger;
    aMinor := lStrArray[1].ToInteger;
    aBuild := lStrArray[2].ToInteger;
  end;
end;
使用
基金会,
帮助者;
osxNSBundle=class
私有的
类函数MainBundle:NSBundle;
公众的
类函数BundlePath:字符串;
类函数BundleVersionStr:string;
类过程BundleVersion(var-aMajor、aMinor、aBuild:integer);
结束;
实施
类函数osxNSBundle.MainBundle:NSBundle;
开始
结果:=TNSBundle.Wrap(TNSBundle.OCClass.mainBundle);
结束;
类函数osxNSBundle.BundlePath:string;
开始
结果:=NSSTROTSTR(MainBundle.bundlePath);
结束;
类函数osxNSBundle.BundleVersionStr:string;
开始
结果:=nsstrotstr(TNSString.Wrap(MainBundle.objectForInfoDictionaryKey(strtonstr('CbundLeverVersion')));
结束;
类过程osxNSBundle.BundleVersion(var aMajor、aMinor、aBuild:integer);
白蜡虫:柏油虫;
i:整数;
开始
aMajor:=0;氨基R=0;ABILD:=0;
lStrArray:=BundleVersionStr.Split(['.]]);
如果长度(lStrArray)>=3,则
开始
aMajor:=lStrArray[0]。ToInteger;
aMinor:=lStrArray[1]。ToInteger;
aBuild:=lStrArray[2]。ToInteger;
结束;
结束;