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)
主站蜘蛛池模板:
堆龙德庆县
|
浦东新区
|
浙江省
|
容城县
|
景东
|
武穴市
|
元阳县
|
南靖县
|
忻城县
|
类乌齐县
|
伊吾县
|
疏勒县
|
英吉沙县
|
乌审旗
|
白玉县
|
梓潼县
|
武鸣县
|
长岛县
|
临沂市
|
东丰县
|
望都县
|
南华县
|
宿州市
|
海兴县
|
沾益县
|
福清市
|
庆城县
|
钦州市
|
明光市
|
汉中市
|
二连浩特市
|
临夏市
|
双城市
|
桐梓县
|
宜兰市
|
木兰县
|
将乐县
|
长乐市
|
鹰潭市
|
江西省
|
靖宇县
|