Esempio n. 1
0
        /// <summary>
        /// Sets a value stored in a NSBundle's info.plist (InfoDictionary).
        /// </summary>
        /// <param name="bundle">The bundle containing the info.plist.</param>
        /// <param name="infoPListKey">The key identifying the info.plist value to set.</param>
        /// <param name="value">The new value to assign for the given key.</param>
        /// <returns><c>true</c>, if thet value was set, <c>false</c> otherwise.</returns>
        public static bool SetPListValue(this NSBundle bundle, string infoPListKey, NSObject value)
        {
            var setValue = false;

            try
            {
                var currentValue = bundle.GetPListValue(infoPListKey);
                if ((currentValue != null) && (value != null) && !currentValue.Equals(value))
                {
                    var info = bundle.InfoDictionary;
                    info.SetValueForKey(value, new NSString(infoPListKey));
                    setValue = true;
                }
            }
            catch (System.Exception)
            {
            }
            return(setValue);
        }