iOS Question How to get ApplicationLabel and Version at runtime?

Discussion in 'iOS Questions' started by davemorris, Feb 14, 2019.

  1. davemorris

    davemorris Member Licensed User

    Hi all,
    Maybe I'm being slow, but I can't seem to find any way to get the app's name and version at runtime?
    I.e. the values of the Project Attributes #ApplicationLabel and #Version that are set in the Main module.

    In B4A I would do it by calling Application.LabelName and Application.VersionName, but the B4i equivalent Application object doesn't appear to have the relevant properties?
     
  2. Pendrush

    Pendrush Well-Known Member Licensed User

    Code:
    Sub AppName As String 
       
    Dim no As NativeObject
       no = no.Initialize(
    "NSBundle").RunMethod("mainBundle"Null)
       
    Dim name As Object = no.RunMethod("objectForInfoDictionaryKey:"Array("CFBundleDisplayName"))
       
    Return name 
    End Sub

    Sub AppVersion As String
       
    Dim no As NativeObject
       no = no.Initialize(
    "NSBundle").RunMethod("mainBundle"Null)
       
    Dim version As Object = no.RunMethod("objectForInfoDictionaryKey:"Array("CFBundleShortVersionString"))
       
    Return version 
    End Sub
     
    fabricio likes this.
  3. davemorris

    davemorris Member Licensed User

    Thanks Pendrush, that works great.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice