3

This is what is returning the error:

NSMutableArray *newArray = [[[NSMutableArray alloc] initWithArray:[NSJSONSerialization JSONObjectWithData:[[[appDelegate.Matches objectAtIndex:(NSUInteger)indexPath] objectForKey:@"chat"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]] addObject:[NSDictionary dictionaryWithObjectsAndKeys:message, @"message", [NSString stringWithFormat:@"%llu", appDelegate.userId], @"id", nil]];
michaela
  • 173
  • 1
  • 2
  • 13
  • 6
    You should really cut down on that line-length. Use extra variables if need be - helps readability. – Anurag May 28 '12 at 21:24
  • 3
    Not only readability, but also debugging. You can actually see which of the ~10 methods you're calling here is the culprit – Sean May 28 '12 at 21:58
  • 3
    The 21st **International Obfuscated C Code Contest** is coming up... http://www.ioccc.org/ . You really should think of entering. – Ashley Mills May 28 '12 at 23:28

1 Answers1

13

"Holy run-on expression, Batman!"

If you were to separate that out into multiple lines, you could easily see where the problem is.

Or, more likely, the error would mysteriously go away.

The problem is that addObject: returns (void), but you are trying to assign the return value of that method to the variable.

bbum
  • 162,346
  • 23
  • 271
  • 359
  • 4
    +1 for "Holy run-on expression, Batman!"... oh and the answer ;) – Paul.s May 28 '12 at 23:25
  • to simplify the code, it isn't that bad to make run-on expressions is it? – michaela Jun 08 '12 at 22:17
  • 1
    Your question demonstrates exactly why it is bad; it hides errors and makes the code more difficult to debug. How, for example, would you step through in the debugger and see the result of executing just the `[appDelegate.Matches objectAtIndex:(NSUInteger)indexPath]` expression? – bbum Jun 08 '12 at 22:37