Twitter with JSON and fetching id from NSDictionary April 17, 2010
Posted by Ameya in 1.Tags: garbeld integer, JSON, NSDictionary, Twitter
2 comments
Was working with twitter API to get tweets in to iPhone. Found another silly issue , which solved with great effort.
Was using some kind of JSON parser ,(will put the name later) , to fetch tweets. every thing was running fine until I wanted to store the latest tweet’s status_id. Here I ran into serious trouble. I was using integer in the database and keeping the tweet_status _id as my tuple (table row) identity. The problem I faced here was all other things converted well like the user id , tweet text etc. when tried to convert status_id would find some garbled entry , really strange. After long unsuccessful efforts in converting twitter status id in to integer , I finally noticed that the size of the number was very big. Bingo the solution was not far just need to convert NSString to double value. So I thought of some fixed approach to deal with twitter data.
- Better not store the converted form of twitter data in the database, for data like status ids, I store it as char or text. Convert it to its true form only when required to compare , like need to store the max status tweet id by comparing with rest tweets id.
- Never keep twitter status as identity in your table. Remember in iPhone your using SQLite db.
- The only two fields can cause serious problem in future in the application are tweet’s status id and tweet’s status’s user id. Better keep them as text and handle them as double. the use id fit as a integer now , but soon will be out of integer scoop.
This post I have put up to show some light to developers goggling for the problem I faced. Please comment to impove this post and, I will include the points it the main post itself.