Read and use data of embeded Info.plist

Discussion in 'iOS Programming' started by alexmalex021, Aug 10, 2015.

  1. alexmalex021 macrumors newbie

    Joined:
    May 19, 2015
    #1
    I wrote a commandline tool for a jailbroken iPhone.for use settings in this tool i create a info.plist file and embed to the binary file(same tool).
    Now i have a question.
    How can i read the info.plist data in the same tool?
    i test some methods.but not working.like:

    id someValue =[[NSBundle mainBundle] objectForInfoDictionaryKey:someKey];


    regards
     
  2. ViviUO macrumors 6502

    Joined:
    Jul 4, 2009
    #2
    First convert info.plist into an NSDictionary:

    Code:
        NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
    
    Then you can read it's objects easily:

    Code:
      NSString *bundleName = info[@"CFBundleName"];
     
  3. alexmalex021, Aug 12, 2015
    Last edited: Aug 12, 2015

    alexmalex021 thread starter macrumors newbie

    Joined:
    May 19, 2015
    #3
    Thanks for your answer.

    I used your method,but it return Null for my specific key.

    i have a simple Info.plist file :
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>reloadTime</key>
        <string>20</string>
    </dict>
    </plist>
    I use this tool for embedding Info.plist to the binary.


    Did you test or used your code?

    Regards
     
  4. ViviUO macrumors 6502

    Joined:
    Jul 4, 2009
    #4
    This was tested using the Info.plist that is generated at project creation
     
  5. alexmalex021, Aug 14, 2015
    Last edited: Aug 15, 2015

    alexmalex021 thread starter macrumors newbie

    Joined:
    May 19, 2015
    #5
    Did you test with commandline iOS tool? in jailbroken iPhone?

    Could you add a new key-value pair to the default Info.plist and test it? test with new key and access new value
    I cannot access
     
  6. alexmalex021, Aug 14, 2015
    Last edited: Aug 15, 2015

    alexmalex021 thread starter macrumors newbie

    Joined:
    May 19, 2015
    #6
    I used a Fat binary.Is that make a problem?

    I tested this method for getting __info_plist data,but this method return wrong data and so cannot convert to plist and nsdictionary.
     

Share This Page