Linyu
Yu
BlogJava
首頁
新隨筆
新文章
聯系
聚合
管理
posts - 9, comments - 0, trackbacks - 0
Iphone中的setting bundle
最近把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
雨
閱讀(1063)
評論(0)
編輯
收藏
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
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.?關于retain和copy(367)
4.?ASIHttpRequest(337)
5.?在工程中加入svn版本號(279)
評論排行榜
1.?在工程中加入svn版本號(0)
2.?Universal工程(0)
3.?查找 EXC_BAD_ACCESS 問題根源的方法(0)
4.?關于retain和copy(0)
5.?去除NSLog(0)
主站蜘蛛池模板:
麻阳
|
双城市
|
黄陵县
|
宿州市
|
莎车县
|
志丹县
|
汨罗市
|
乡宁县
|
邵阳县
|
明星
|
垣曲县
|
洪江市
|
荃湾区
|
东乌珠穆沁旗
|
千阳县
|
东乌
|
武安市
|
宽甸
|
玛曲县
|
庆城县
|
武宣县
|
湖口县
|
石家庄市
|
元氏县
|
修文县
|
团风县
|
都昌县
|
区。
|
宁陵县
|
内丘县
|
吉首市
|
秦安县
|
伊春市
|
天水市
|
田东县
|
丰原市
|
兴化市
|
剑阁县
|
两当县
|
凤庆县
|
江口县
|