facebook/facebook-ios-sdk — Issue #399: Arithmetic exception for user with no friends asking to post on friend's wall
Author: Frizlab
Created: 2011-10-12 00:15:49+00:00
State: open

If a user with no friends logs in and asks to publish a story on a friend's wall, the application will crash with an arithmetic exception. This is due to a very small bug. Here is a fix:

```
diff --git a/sample/Hackbook/Hackbook/APICallsViewController.m b/sample/Hackbook/Hackbook/APICallsViewController.m
index 54cb87e..35572e4 100644
--- a/sample/Hackbook/Hackbook/APICallsViewController.m
+++ b/sample/Hackbook/Hackbook/APICallsViewController.m
@@ -968,7 +968,7 @@
{
NSArray *resultData = [result objectForKey:@"data"];
// Check that the user has friends
- if ([result count] > 0) {
+ if ([resultData count] > 0) {
// Pick a random friend to post the feed to
int randomNumber = arc4random() % [resultData count];
[self apiDialogFeedFriend:[[resultData objectAtIndex:randomNumber] objectForKey:@"id"]];
```