Linyu
Yu
BlogJava
首頁
新隨筆
新文章
聯(lián)系
聚合
管理
posts - 9, comments - 0, trackbacks - 0
Iphone中的setting bundle
最近把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)站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Copyright ©2025 雨 Powered by:
博客園
模板提供:
滬江博客
<
2010年10月
>
日
一
二
三
四
五
六
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
常用鏈接
我的隨筆
我的評論
我的參與
留言簿
(1)
給我留言
查看公開留言
查看私人留言
隨筆檔案
2011年8月 (1)
2011年6月 (1)
2011年2月 (1)
2010年12月 (2)
2010年10月 (4)
文章分類
Iphone
搜索
最新評論
閱讀排行榜
1.?Iphone中的setting bundle(1063)
2.?查找 EXC_BAD_ACCESS 問題根源的方法(377)
3.?關(guān)于retain和copy(367)
4.?ASIHttpRequest(337)
5.?在工程中加入svn版本號(279)
評論排行榜
1.?在工程中加入svn版本號(0)
2.?Universal工程(0)
3.?查找 EXC_BAD_ACCESS 問題根源的方法(0)
4.?關(guān)于retain和copy(0)
5.?去除NSLog(0)
主站蜘蛛池模板:
乳山市
|
长顺县
|
虹口区
|
密云县
|
嘉祥县
|
阳原县
|
普定县
|
中江县
|
屏边
|
新郑市
|
嘉黎县
|
沙河市
|
闵行区
|
明溪县
|
嘉禾县
|
绿春县
|
华阴市
|
河西区
|
长治县
|
乌海市
|
曲阳县
|
清水县
|
平凉市
|
郴州市
|
信丰县
|
溧水县
|
马公市
|
什邡市
|
辽源市
|
安西县
|
方城县
|
靖州
|
苍溪县
|
河津市
|
湛江市
|
泌阳县
|
镇雄县
|
邢台市
|
禹城市
|
乡城县
|
阿瓦提县
|