English 中文(简体)
来自复杂的YouTube的JSON的NSDtionaries和NSArrays
原标题:NSDictionaries and NSArrays from JSON from complicated YouTube API

I m 制成一盘旋式扫描仪,利用JSON AP搜索YouTube视频。 然而,谷歌是 la的,因此它们只是将ATOM的饲料转化为JSON。 类似情况:

feed->entry[0]->author[0]->name->$t

这意味着很难从国家航空航天局获取信息,因为我需要获得一系列关键物体的关键物品。

To check if the structure is correct, I can choose two things:

  1. Use a huge amount of code for each item I want to check if the JSON was correct.
  2. Wrap everything in a @try block.

我要选择第二点。 问题是,我刚才读过,这是不好的做法。 是的? 如果是的话,验证NSDictionaries的NSArrays的方法是否较短? 我的 app可能永远不会坠毁,即使用户在操作时间搬走了处理器,因此根本不能检查。

您能否帮助我? 感谢。

最佳回答

您是否尝试过GData AP? http://itunes.apple.com/us/app/skystop/id392782307?mt=8'rel=“nofollow”http://itunes.apple.com/us/app/skystop/id392782307?mt=8。 它基本上将XML档案用于你要求的任何工作,而且你可以将它变成一个名单或一个NSArray。

问题回答

i m not sure i understand, the API itself works in JSON instead of ATOM so you need to di into every item ? If this is so then you are right, not much you can do except to seardch the web for helper libraries that might have been made even in google code to support this API.

In any case #2 is bad practice first of all since try catch usually consume more system resources then simple boolean cheek or checks. Second once you are in the catch block you are kind of in problem since all you can do is print an error to the user or yourself, if you want to go on parsing and checking, you can t... and last but not least (I m sure there are reasons I m not thinking of) except for the message you might get with the exception u are never to sure where it came from...





相关问题
Separating Business Layer Errors from API errors

The title is horrible, i know; I m terrible at titles on SO here. I m wondering what would be the best way to present unified error responses in a webapi when errors could be raised deep inside the ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

How to tell why a file deletion fails in Java?

File file = new File(path); if (!file.delete()) { throw new IOException( "Failed to delete the file because: " + getReasonForFileDeletionFailureInPlainEnglish(file)); } Is there a ...

Exceptions: redirect or render?

I m trying to standardize the way I handle exceptions in my web application (homemade framework) but I m not certain of the "correct" way to handle various situations. I m wondering if there is a ...

热门标签