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
雨
閱讀(1064)
評論(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(1064)
2.?查找 EXC_BAD_ACCESS 問題根源的方法(379)
3.?關于retain和copy(369)
4.?ASIHttpRequest(338)
5.?在工程中加入svn版本號(280)
評論排行榜
1.?在工程中加入svn版本號(0)
2.?Universal工程(0)
3.?查找 EXC_BAD_ACCESS 問題根源的方法(0)
4.?關于retain和copy(0)
5.?去除NSLog(0)
主站蜘蛛池模板:
宝应县
|
龙游县
|
乌兰浩特市
|
乌恰县
|
宁波市
|
从化市
|
肥西县
|
庆城县
|
陵水
|
天镇县
|
永春县
|
霍山县
|
乐业县
|
麻栗坡县
|
桐梓县
|
那坡县
|
望城县
|
齐齐哈尔市
|
万宁市
|
桑日县
|
琼海市
|
文成县
|
罗城
|
水城县
|
哈尔滨市
|
岫岩
|
阿克苏市
|
新宁县
|
浮山县
|
武穴市
|
山东
|
东乡县
|
文山县
|
砀山县
|
石首市
|
台北县
|
穆棱市
|
新昌县
|
日照市
|
淮阳县
|
河南省
|