Hey Guys,
(a bit of background in case you are interested) I am a reasonably proficient programmer, but have only been using XCode and Obj C for the past half a year of so to create a tool for my Master's degree thesis.
Anyways, on a few occasions I have had cases where nested message passes/function calls do not work (either compile or run-time errors), but when I break things up it works. Usually nesting is no problem, but occasionally it happens. I usually assume I am just doing something wrong that I can't figure out. Here is an example: (basically, transition is an instance of an object with a variableResets member array which I want to add an object, variableReset)
(broken up)
NSMutableArray* arr = [transition variableResets];
[arr addObject:variableReset];
[transition setVariableResets:arr];
(one line)
[transition setVariableResets:[[transition variableResets] addObject:variableReset]];
The one line version gives me a compile error of "invalid use of void function." Both setVariableResets and addObject are void functions, but I can't see how either are being used incorrectly. And variableResets does return a mutable array, but I am guessing that it somehow has to do with something like that.
It's probably some sort of simple thing that I am just overlooking or unaware of, but maybe someone knows what the error is. And I'll stress that I really don't care about having to break it up, but it really puzzles me as to why?
(a bit of background in case you are interested) I am a reasonably proficient programmer, but have only been using XCode and Obj C for the past half a year of so to create a tool for my Master's degree thesis.
Anyways, on a few occasions I have had cases where nested message passes/function calls do not work (either compile or run-time errors), but when I break things up it works. Usually nesting is no problem, but occasionally it happens. I usually assume I am just doing something wrong that I can't figure out. Here is an example: (basically, transition is an instance of an object with a variableResets member array which I want to add an object, variableReset)
(broken up)
NSMutableArray* arr = [transition variableResets];
[arr addObject:variableReset];
[transition setVariableResets:arr];
(one line)
[transition setVariableResets:[[transition variableResets] addObject:variableReset]];
The one line version gives me a compile error of "invalid use of void function." Both setVariableResets and addObject are void functions, but I can't see how either are being used incorrectly. And variableResets does return a mutable array, but I am guessing that it somehow has to do with something like that.
It's probably some sort of simple thing that I am just overlooking or unaware of, but maybe someone knows what the error is. And I'll stress that I really don't care about having to break it up, but it really puzzles me as to why?