我發現了一個奇怪的行爲,當我顯示JSON對象在字典中解析的結果,然後打印在alertView上(在Xcode 5.1.1上,在iOS 64位模擬器上爲iOS 7.1編譯)。出於同樣的inputData:
[[UIAlertView alloc]initWithTitle:@"something" message:[[[NSString stringWithFormat:@"json:%@",[inputData dictionaryRepresentation]] stringByReplacingOccurrencesOfString:@" "withString:@""]substringToIndex:7035] delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
打印正確,但如果我說「substringToIndex:7036」,僅顯示空白......沒有「stringByReplacingOccurrencesOfString:」法的限制遠遠超出:
[[UIAlertView alloc]initWithTitle:@"something" message:[[NSString stringWithFormat:@"json:%@",[inputData dictionaryRepresentation]] substringToIndex:13768] delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
正確打印,而不是「substringToIndex:13769」不打印...我意識到這不是一個最大長度的問題,但在JSON對象內的特殊字符
你想要顯示的文本就像一個段落? –
使你自己的警報視圖更容易 – amar