2016-05-24 59 views
1

如何將我的firebase數據放入Textview?進來的信息是作爲一個NSDictionary。Firebase NSDictionary到Textview

2016-05-24 10:15:45.523 Weather[1248:29689] { 
baro = 1; 
humidity = 3; 
temp = 2; 
} 

我試圖轉換爲字符串,然後轉換爲textview,但這不起作用?

Firebase *usersRef = [ref childByAppendingPath: @"id/"]; 

[usersRef observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) { 
    NSLog(@"%@ -> %@", snapshot.key, snapshot.value); 


    NSLog(@"%@", snapshot.value); 

    string1 = snapshot.value; 

任何幫助將不勝感激。

+0

所以最新的問題,你需要字符串?你需要testView? – Alok

+0

我想把所有的信息放入一個textview,我知道該怎麼做。 – vype

+0

'[snapshot.value objectForKey:@「Your Key」];'嘗試一次..將其添加到textview.text ....希望這可以工作 –

回答

2

試試這個

NSDictionary *dict=[NSDictionary dictionaryWithDictionary:snapshot.value]; 
NSString *stri=[NSString stringWithFormat:@"%@",dict]; 

我有導致像這樣的TextView的 enter image description here

這可能不是你想要什麼,但是,這將幫助您開始。 希望這有助於。

+0

是的,它確實沒有任何問題地將數據抓取到textview。是的,從這裏我至少可以開始。謝謝 – vype

+0

我歡迎.... @ vype –