The file can be viewed here. I am parsing for the attribute "likes" but I am getting <null>
even when I have liked the post. I am 100% sure my modhash is valid, and when I view the file I can see that true is appearing for posts I have upvoted.
My Code:
NSData *responseData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://reddit.com/.json"]];
NSDictionary *json = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSArray *objects = [[json objectForKey:@"data"] objectForKey:@"children"];
postArr = [[NSMutableArray alloc] init];
int likesCnt = 0;
for (NSDictionary *object in objects) {
NSObject *likeObj = [[object objectForKey:@"data"] objectForKey:@"likes"] ;
NSObject *data = [object objectForKey:@"data"];
int voteDirection = 0;
if(![likeObj isKindOfClass:[NSNull class]] && [[data valueForKey:@"likes"] boolValue])
voteDirection = 1;
else if(![likeObj isKindOfClass:[NSNull class]] && ![[data valueForKey:@"likes"] boolValue])
voteDirection = -1;
//Reddit Post in an NSObject Class for organizing info for specific posts.
RedditPost *post = postArr[likesCnt];
post.currentVote = voteDirection;
postArr[likesCnt] = post;
NSLog(@"Title:(%@) Vote:(%d)",post.title,voteDirection);
likesCnt++;
}
New file: http://www1.datafilehost.com/d/25dae11d