English 中文(简体)
MacRuby: How to Read a plist file?
原标题:MacRuby: How to read a plist file?

我必须这样做是简单易懂的,但不能在网上找到一个基本的例子。 我如何利用Mac Ruby在我的项目中读取一份清单数据?

Solution:

Turns out there s a few different ways to do it, but the cleanest I ve found (so far) is to use the MacRuby helper method load_plist (which turns a plist file s contents into a hash). Also, if you re using XCode, you will need to get the file path relative to your app bundle:

# there s an AppConfig.plist file in my app bundle

config_path = NSBundle.mainBundle.pathForResource( AppConfig , ofType:  plist )
@config = load_plist File.read(config_path)
最佳回答
问题回答

暂无回答




相关问题
Xcode cannnot find my plist file when building

I m trying to build my app and every time I do I get this error: error: The file "Wallpapers-Info.plist" does not exist. Anyone know what causes this error? I have the wallpaper-info.plist file ...

Copying JSON response dictionary to plist

I have a dictionary containing a JSON response and a plist file. I want to update the values in my plist file with the JSON response values. How would I do this?

Use a Plist dictionary for App settings

I want to be able to use a plist for settings Im implementing in my app. I want a dictionary "Settings" to hold my arrays, such as "Debug", "Option 1", Option 2", etc. How would I access "Debug"array ...

How to add an extra plist property using CMake?

I m trying to add the item <key>UIStatusBarHidden</key><true/> to my plist that s auto-generated by CMake. For certain keys, it appears there are pre-defined ways to add an item; ...

Plist Hierarchy and All Option

I have a string of data in a plist, which I ve got to display, hierarchically like this: Menu>Chapter>SubChapter>item>item details This might be super simple, in my initial menu, how would I have ...

热门标签