posts - 9,  comments - 0,  trackbacks - 0
          最近把xcode升級后發現加入settingbundle取出的defaultValue一直是nil
          一直找不到原因
          所以就用以下方法了,希望能對大家有幫助

          -(void)initvalue
          {
              NSString 
          *url=[[NSUserDefaults standardUserDefaults] objectForKey:kConnection];
              
          if (url==nil) {
                  NSString 
          *stringBundle=[[NSBundle mainBundle] bundlePath];
                  NSString 
          *settingBundle=[stringBundle stringByAppendingPathComponent:@"Settings.bundle"];
                  NSString
          *listBundle=[settingBundle stringByAppendingPathComponent:@"Root.plist"];
                  NSDictionary
          *rootDict=[NSDictionary dictionaryWithContentsOfFile:listBundle];
                  NSArray
          *array=[rootDict objectForKey:@"PreferenceSpecifiers"];
                  NSDictionary
          *preItem;
                  NSString
          *connection=nil;
                  
          for (preItem in array) {
                      NSString
          *key=[preItem objectForKey:@"Key"];
                      id defaultValue
          =[preItem objectForKey:@"DefaultValue"];
                      
          if ([key isEqualToString:@"connection"]) {
                          connection
          =@" http://www.baidu.com";
                      }

                  }

                  NSDictionary 
          *dictionary=[[NSDictionary alloc]initWithObjectsAndKeys:connection,@"connection",nil];
                  [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
                  [[NSUserDefaults standardUserDefaults] synchronize];
                  [dictionary release];
                  [stringBundle release];
                  [rootDict release];
                  [preItem release];
              }

          }
          這只是初始化Root.plist里的值,在這里我加入了一個PSTextFieldSpecifier,
          posted on 2010-10-28 09:11 閱讀(1064) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2010年10月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 宝应县| 龙游县| 乌兰浩特市| 乌恰县| 宁波市| 从化市| 肥西县| 庆城县| 陵水| 天镇县| 永春县| 霍山县| 乐业县| 麻栗坡县| 桐梓县| 那坡县| 望城县| 齐齐哈尔市| 万宁市| 桑日县| 琼海市| 文成县| 罗城| 水城县| 哈尔滨市| 岫岩| 阿克苏市| 新宁县| 浮山县| 武穴市| 山东| 东乡县| 文山县| 砀山县| 石首市| 台北县| 穆棱市| 新昌县| 日照市| 淮阳县| 河南省|