posts - 9,  comments - 0,  trackbacks - 0
          最近把xcode升級后發(fā)現(xiàn)加入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 閱讀(1063) 評論(0)  編輯  收藏

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


          網(wǎng)站導航:
           
          <2010年10月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 乳山市| 长顺县| 虹口区| 密云县| 嘉祥县| 阳原县| 普定县| 中江县| 屏边| 新郑市| 嘉黎县| 沙河市| 闵行区| 明溪县| 嘉禾县| 绿春县| 华阴市| 河西区| 长治县| 乌海市| 曲阳县| 清水县| 平凉市| 郴州市| 信丰县| 溧水县| 马公市| 什邡市| 辽源市| 安西县| 方城县| 靖州| 苍溪县| 河津市| 湛江市| 泌阳县| 镇雄县| 邢台市| 禹城市| 乡城县| 阿瓦提县|